From 6d066f2619da7a01f32f9bbdf78bfc3df9e7a5db Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 17 Nov 2026 17:01:25 +0100 Subject: [PATCH] feat: add state store --- src/stores/statestore.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/stores/statestore.ts 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 + }; +} );