diff --git a/package.json b/package.json index c10f86b84..60f65b129 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,7 @@ "vue": "3.5.22", "vue-i18n": "11", "vue-router": "4.6.4", - "vue-virtual-scroller": "^2.0.0-beta.7", - "vuex": "4.1.0" + "vue-virtual-scroller": "^2.0.0-beta.7" }, "devDependencies": { "@babel/core": "7.28.5", diff --git a/src/lib/persisted_state.js b/src/lib/persisted_state.js index a4dfe7d00..d4e0b1de2 100644 --- a/src/lib/persisted_state.js +++ b/src/lib/persisted_state.js @@ -27,73 +27,6 @@ const defaultStorage = (() => { return storage })() -export default function createPersistedState({ - key = 'vuex-lz', - paths = [], - getState = (key, storage) => { - const value = storage.getItem(key) - return value - }, - setState = (key, state, storage) => { - if (!loaded) { - console.info('waiting for old state to be loaded...') - return Promise.resolve() - } else { - return storage.setItem(key, state) - } - }, - reducer = defaultReducer, - storage = defaultStorage, - subscriber = (store) => (handler) => store.subscribe(handler), -} = {}) { - return getState(key, storage).then((savedState) => { - return (store) => { - try { - if (savedState !== null && typeof savedState === 'object') { - // build user cache - const usersState = savedState.users || {} - usersState.usersObject = {} - const users = usersState.users || [] - each(users, (user) => { - usersState.usersObject[user.id] = user - }) - savedState.users = usersState - - store.replaceState(merge({}, store.state, savedState)) - } - loaded = true - } catch (e) { - console.error("Couldn't load state") - console.error(e) - loaded = true - } - subscriber(store)((mutation, state) => { - try { - if (saveImmedeatelyActions.includes(mutation.type)) { - setState(key, reducer(cloneDeep(state), paths), storage).then( - (success) => { - if (success !== undefined) { - if (mutation.type === 'setOption') { - useInterfaceStore().settingsSaved({ success }) - } - } - }, - (error) => { - if (mutation.type === 'setOption') { - useInterfaceStore().settingsSaved({ error }) - } - }, - ) - } - } catch (e) { - console.error("Couldn't persist state:") - console.error(e) - } - }) - } - }) -} - /** * This persists state for pinia, which falls back to read from the vuex state * if pinia persisted state does not exist. diff --git a/src/main.js b/src/main.js index bb76a1cf0..f3615d955 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,6 @@ /* global process */ import { createPinia } from 'pinia' -import { createStore } from 'vuex' import 'custom-event-polyfill' import './lib/event_target_polyfill.js' @@ -17,11 +16,8 @@ import { createI18n } from 'vue-i18n' import afterStoreSetup from './boot/after_store.js' import messages from './i18n/messages.js' -import createPersistedState, { - piniaPersistPlugin, -} from './lib/persisted_state.js' +import { piniaPersistPlugin } from './lib/persisted_state.js' import { piniaPushNotificationsPlugin } from './lib/push_notifications_plugin.js' -import vuexModules from './modules/index.js' import { piniaLanguagePlugin } from 'src/lib/language.js' import { piniaStylePlugin } from 'src/lib/style.js' @@ -69,20 +65,12 @@ const persistedStateOptions = { try { let storageError - const plugins = [] const pinia = createPinia() pinia.use(piniaPersistPlugin()) pinia.use(piniaLanguagePlugin) pinia.use(piniaStylePlugin) pinia.use(piniaPushNotificationsPlugin) - try { - const persistedState = await createPersistedState(persistedStateOptions) - plugins.push(persistedState) - } catch (e) { - console.error('Storage error', e) - storageError = e - } document.querySelector('#splash').classList.remove('initial-hidden') document.querySelector('#mascot').src = `/static/pleromatan_apology${isFox}_small.webp` @@ -93,17 +81,8 @@ const persistedStateOptions = { 'update.art_by', { linkToArtist: 'pipivovott' }, ) - const store = createStore({ - modules: vuexModules, - plugins, - options: { - devtools: process.env.NODE_ENV !== 'production', - }, - strict: false, // Socket modifies itself, let's ignore this for now. - // strict: process.env.NODE_ENV !== 'production' - }) - // Temporarily passing pinia and vuex stores along with storageError result until migration is fully complete. - return await afterStoreSetup({ pinia, store, storageError, i18n }) + // Temporarily passing pinia stores along with storageError result until migration is fully complete. + return await afterStoreSetup({ pinia, storageError, i18n }) } catch (e) { splashError(i18n, e) } diff --git a/test/fixtures/mock_store.js b/test/fixtures/mock_store.js deleted file mode 100644 index b3380834c..000000000 --- a/test/fixtures/mock_store.js +++ /dev/null @@ -1,22 +0,0 @@ -import { cloneDeep } from 'lodash' -import { createStore } from 'vuex' - -import vuexModules from 'src/modules/index.js' - -const tweakModules = (modules) => { - const res = {} - Object.entries(modules).forEach(([name, module]) => { - const m = { ...module } - m.state = cloneDeep(module.state) - res[name] = m - }) - return res -} - -const makeMockStore = () => { - return createStore({ - modules: tweakModules(vuexModules), - }) -} - -export default makeMockStore diff --git a/yarn.lock b/yarn.lock index 4913bcfb7..364949865 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2877,7 +2877,7 @@ "@vue/compiler-dom" "3.5.35" "@vue/shared" "3.5.35" -"@vue/devtools-api@^6.0.0-beta.11", "@vue/devtools-api@^6.5.0", "@vue/devtools-api@^6.6.4": +"@vue/devtools-api@^6.5.0", "@vue/devtools-api@^6.6.4": version "6.6.4" resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.6.4.tgz#cbe97fe0162b365edc1dba80e173f90492535343" integrity sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g== @@ -9190,13 +9190,6 @@ vue@^3.5.35: "@vue/server-renderer" "3.5.35" "@vue/shared" "3.5.35" -vuex@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/vuex/-/vuex-4.1.0.tgz#aa1b3ea5c7385812b074c86faeeec2217872e36c" - integrity sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ== - dependencies: - "@vue/devtools-api" "^6.0.0-beta.11" - w3c-xmlserializer@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz#f925ba26855158594d907313cedd1476c5967f6c"