2021-07-29 18:02:36 +02:00
|
|
|
import { writable } from "svelte/store";
|
|
|
|
import Timeout = NodeJS.Timeout;
|
2021-05-12 18:32:55 +02:00
|
|
|
|
2021-08-09 14:49:17 +02:00
|
|
|
export const menuIconVisiblilityStore = writable(false);
|
|
|
|
export const menuVisiblilityStore = writable(false);
|
|
|
|
export const menuInputFocusStore = writable(false);
|
2021-07-29 18:02:36 +02:00
|
|
|
|
|
|
|
let warningContainerTimeout: Timeout | null = null;
|
|
|
|
function createWarningContainerStore() {
|
|
|
|
const { subscribe, set } = writable<boolean>(false);
|
|
|
|
|
|
|
|
return {
|
|
|
|
subscribe,
|
|
|
|
activateWarningContainer() {
|
|
|
|
set(true);
|
|
|
|
if (warningContainerTimeout) clearTimeout(warningContainerTimeout);
|
|
|
|
warningContainerTimeout = setTimeout(() => {
|
|
|
|
set(false);
|
|
|
|
warningContainerTimeout = null;
|
|
|
|
}, 120000);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export const warningContainerStore = createWarningContainerStore();
|
2021-08-11 14:07:34 +02:00
|
|
|
|
|
|
|
export enum SubMenusInterface {
|
|
|
|
settings = "Settings",
|
|
|
|
profile = "Profile",
|
|
|
|
createMap = "Create a Map",
|
|
|
|
aboutRoom = "About the Room",
|
|
|
|
globalMessages = "Global Messages",
|
|
|
|
contact = "Contact",
|
|
|
|
}
|
|
|
|
|
|
|
|
function createSubMenusStore() {
|
|
|
|
const { subscribe, update } = writable<string[]>([
|
|
|
|
SubMenusInterface.settings,
|
|
|
|
SubMenusInterface.profile,
|
|
|
|
SubMenusInterface.createMap,
|
|
|
|
SubMenusInterface.aboutRoom,
|
|
|
|
SubMenusInterface.globalMessages,
|
|
|
|
SubMenusInterface.contact,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return {
|
|
|
|
subscribe,
|
|
|
|
addMenu(menuCommand: string) {
|
|
|
|
update((menuList: string[]) => {
|
|
|
|
if (!menuList.find((menu) => menu === menuCommand)) {
|
|
|
|
menuList.push(menuCommand);
|
|
|
|
}
|
|
|
|
return menuList;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
removeMenu(menuCommand: string) {
|
|
|
|
update((menuList: string[]) => {
|
|
|
|
const index = menuList.findIndex((menu) => menu === menuCommand);
|
|
|
|
if (index !== -1) {
|
|
|
|
menuList.splice(index, 1);
|
|
|
|
}
|
|
|
|
return menuList;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export const subMenusStore = createSubMenusStore();
|