Skip to content

Commit

Permalink
fix: Dark mode bug, pinia store reset across Vite entry points (#7851)
Browse files Browse the repository at this point in the history
  • Loading branch information
holloway authored Aug 23, 2024
1 parent d3fe1c0 commit af21347
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/embedded.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions client/main.js
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
6 changes: 6 additions & 0 deletions client/shared/create-pinia-singleton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createPinia } from 'pinia'

export function createPiniaSingleton(){
window.pinia = window.pinia ?? createPinia()
return window.pinia
}

3 comments on commit af21347

@S1H2B3

This comment was marked as spam.

@S1H2B3

This comment was marked as spam.

@mutpk

This comment was marked as spam.

Please sign in to comment.