added store with actions for actionsMenu
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export interface ActionsMenuInterface {
|
||||
displayName: string;
|
||||
callback: Function;
|
||||
}
|
||||
|
||||
function createActionsMenuStore() {
|
||||
|
||||
const actions = new Map<string, ActionsMenuInterface>();
|
||||
const { subscribe, update, set } = writable<Map<string, ActionsMenuInterface>>(actions);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
addPossibleAction: (key: string, displayName: string, callback: Function) => {
|
||||
update((actions) => {
|
||||
actions.set(key, { displayName, callback });
|
||||
return actions;
|
||||
});
|
||||
},
|
||||
removePossibleAction: (key: string) => {
|
||||
update((actions) => {
|
||||
actions.delete(key);
|
||||
return actions;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Hides menu
|
||||
*/
|
||||
clearActions: () => {
|
||||
set(new Map<string, ActionsMenuInterface>());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const actionsMenuStore = createActionsMenuStore();
|
||||
@@ -4,7 +4,7 @@ export const userMovingStore = writable(false);
|
||||
|
||||
export const requestVisitCardsStore = writable<string | null>(null);
|
||||
|
||||
export const requestActionsMenuStore = writable(true);
|
||||
export const requestActionsMenuStore = writable(false);
|
||||
|
||||
export const userIsAdminStore = writable(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user