]> git.r.bdr.sh - rbdr/forum/blob - src/stores/actions.js
ae0190624c751017923a92d9c6ae37364173a28c
[rbdr/forum] / src / stores / actions.js
1 import { derived, writable } from 'svelte/store';
2
3 /*
4 * This is a store to set the actions in the top header.
5 */
6
7 export const actions = writable({});
8
9 export const enableTopicActions = (id) => {
10
11 actions.update((actionsValue) => {
12
13 actionsValue.topic = {
14 id
15 };
16 return actionsValue;
17 });
18 };
19
20 export const disableTopicActions = () => {
21
22 actions.update((actionsValue) => {
23
24 delete actionsValue.topic;
25 return actionsValue;
26 });
27 };
28
29 export const topicActions = derived(
30 actions,
31 ($actions) => $actions.topic
32 );