diff --git a/client/embedded.js b/client/embedded.js index 3b104650cf..0509c0aecf 100644 --- a/client/embedded.js +++ b/client/embedded.js @@ -1,11 +1,11 @@ import { createApp } from 'vue' -import { createPinia } from 'pinia' import piniaPersist from 'pinia-plugin-persist' import Embedded from './Embedded.vue' +import { createPiniaSingleton } from './shared/create-pinia-singleton' // Initialize store (Pinia) -const pinia = createPinia() +const pinia = createPiniaSingleton() pinia.use(piniaPersist) // Mount App diff --git a/client/main.js b/client/main.js index 0dc5cf32e0..3fbad907b1 100644 --- a/client/main.js +++ b/client/main.js @@ -1,14 +1,14 @@ import { createApp } from 'vue' -import { createPinia } from 'pinia' import piniaPersist from 'pinia-plugin-persist' import App from './App.vue' import router from './router' +import { createPiniaSingleton } from './shared/create-pinia-singleton' const app = createApp(App, {}) // Initialize store (Pinia) -const pinia = createPinia() +const pinia = createPiniaSingleton() pinia.use(piniaPersist) app.use(pinia) diff --git a/client/shared/create-pinia-singleton.js b/client/shared/create-pinia-singleton.js new file mode 100644 index 0000000000..f0013245a1 --- /dev/null +++ b/client/shared/create-pinia-singleton.js @@ -0,0 +1,6 @@ +import { createPinia } from 'pinia' + +export function createPiniaSingleton(){ + window.pinia = window.pinia ?? createPinia() + return window.pinia +}