diff --git a/src/store/index.tsx b/src/store/index.tsx index fb49732d..d9e89bf8 100644 --- a/src/store/index.tsx +++ b/src/store/index.tsx @@ -16,6 +16,7 @@ import { chatHistoryStore } from './chat'; function hydrateAll() { Promise.all([hydrate('main', mainStore), hydrate('ui', uiStore)]).then(() => { + mainStore.initializeSessionId(); uiStore.setReady(true); }); } diff --git a/src/store/main.ts b/src/store/main.ts index f7f6b9d1..f73884da 100644 --- a/src/store/main.ts +++ b/src/store/main.ts @@ -2093,6 +2093,25 @@ export class MainStore { } } + @observable + sessionId = ''; + + @action setSessionId(id: string) { + this.sessionId = id; + } + + initializeSessionId() { + let sessionId = sessionStorage.getItem('sphinx_session_id'); + + if (!sessionId) { + sessionId = randomString(32); + sessionStorage.setItem('sphinx_session_id', sessionId); + } + + this.setSessionId(sessionId); + return sessionId; + } + @persist('object') @observable keysendInvoice = '';