diff --git a/src/stores/statestore.ts b/src/stores/statestore.ts new file mode 100644 index 0000000..335b978 --- /dev/null +++ b/src/stores/statestore.ts @@ -0,0 +1,30 @@ +import { + defineStore +} from 'pinia'; +import { + ref +} from 'vue'; + +export const useStateStore = defineStore( 'statestore', () => { + const selectedSubject = ref( -1 ); + const selectedSubtopic = ref( -1 ); + const selectedChat = ref( -1 ); + + try { + selectedSubject.value = parseInt( localStorage.getItem( 'sp-selected-subject' )! ); + } catch { /* */ } + + try { + selectedSubtopic.value = parseInt( localStorage.getItem( 'sp-selected-subtopic' )! ); + } catch { /* */ } + + try { + selectedChat.value = parseInt( localStorage.getItem( 'sp-selected-chat' )! ); + } catch { /* */ } + + return { + selectedSubject, + selectedSubtopic, + selectedChat + }; +} );