implement migration

This commit is contained in:
Henry Jameson 2025-03-25 11:56:17 +02:00
commit 5d47ac04b0
4 changed files with 37 additions and 4 deletions

View file

@ -46,6 +46,7 @@
"querystring-es3": "0.2.1", "querystring-es3": "0.2.1",
"url": "0.11.4", "url": "0.11.4",
"utf8": "3.0.0", "utf8": "3.0.0",
"uuid": "8.3.2",
"vue": "3.5.13", "vue": "3.5.13",
"vue-i18n": "10", "vue-i18n": "10",
"vue-router": "4.5.0", "vue-router": "4.5.0",

View file

@ -18,7 +18,6 @@ const saveImmedeatelyActions = [
'markNotificationsAsSeen', 'markNotificationsAsSeen',
'clearCurrentUser', 'clearCurrentUser',
'setCurrentUser', 'setCurrentUser',
'setServerSideStorage',
'setHighlight', 'setHighlight',
'setOption', 'setOption',
'setClientData', 'setClientData',

View file

@ -1,13 +1,15 @@
import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash'
import { v4 as uuidv4 } from 'uuid';
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import { windowWidth, windowHeight } from '../services/window_utils/window_utils' import { windowWidth, windowHeight } from '../services/window_utils/window_utils'
import apiService from '../services/api/api.service.js' import apiService from '../services/api/api.service.js'
import oauthApi from '../services/new_api/oauth.js' import oauthApi from '../services/new_api/oauth.js'
import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash'
import { registerPushNotifications, unregisterPushNotifications } from '../services/sw/sw.js' import { registerPushNotifications, unregisterPushNotifications } from '../services/sw/sw.js'
import { useInterfaceStore } from 'src/stores/interface.js' import { useInterfaceStore } from 'src/stores/interface.js'
import { useOAuthStore } from 'src/stores/oauth.js' import { useOAuthStore } from 'src/stores/oauth.js'
import { useServerSideStorageStore } from 'src/stores/serverSideStorage' import { useServerSideStorageStore, CONFIG_MIGRATION } from 'src/stores/serverSideStorage'
// TODO: Unify with mergeOrAdd in statuses.js // TODO: Unify with mergeOrAdd in statuses.js
export const mergeOrAdd = (arr, obj, item) => { export const mergeOrAdd = (arr, obj, item) => {
@ -618,6 +620,37 @@ const users = {
// Set our new backend interactor // Set our new backend interactor
commit('setBackendInteractor', backendInteractorService(accessToken)) commit('setBackendInteractor', backendInteractorService(accessToken))
// Do server-side storage migrations
const { configMigration } = useServerSideStorageStore().flagStorage
// Wordfilter migration
if (configMigration < 1) {
// Debug snippet to clean up storage
/*
Object.keys(useServerSideStorageStore().prefsStorage.simple.muteFilters).forEach(key => {
useServerSideStorageStore().unsetPreference({ path: 'simple.muteFilters.' + key, value: null })
})
*/
// Convert existing wordfilter into synced one
store.rootState.config.muteWords.forEach(word => {
const uniqueId = uuidv4()
useServerSideStorageStore().setPreference({
path: 'simple.muteFilters.' + uniqueId,
value: {
type: 'word',
value: word
}
})
})
}
// Update the flag
useServerSideStorageStore().setflag({ flag: 'configMigration', value: CONFIG_MIGRATION })
useServerSideStorageStore().pushServerSideStorage() useServerSideStorageStore().pushServerSideStorage()
if (user.token) { if (user.token) {

View file

@ -38,7 +38,7 @@ export const defaultState = {
simple: { simple: {
dontShowUpdateNotifs: false, dontShowUpdateNotifs: false,
collapseNav: false, collapseNav: false,
filters: {} muteFilters: {}
}, },
collections: { collections: {
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'], pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],