From 3b850ae2231d8d67c6b4257c5c8d4cabd02c5601 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 13 Mar 2026 12:11:43 +0200 Subject: [PATCH 1/3] fix --- src/stores/user_highlight.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/stores/user_highlight.js b/src/stores/user_highlight.js index 78bb3c4dc..d3456741f 100644 --- a/src/stores/user_highlight.js +++ b/src/stores/user_highlight.js @@ -272,20 +272,21 @@ export const useUserHighlightStore = defineStore('user_highlight', { let { recent, stale, needUpload } = _getRecentData(cache, live) + const userNew = userData.created_at > NEW_USER_DATE + let dirty = false + const vuexState = await storage.getItem('vuex-lz') const { highlight } = vuexState.config Object.entries(highlight).forEach(([user, value]) => { - if ((highlight[user]._migrated || 0) < 2) { + if ((highlight[user]._migrated || 0) < 1) { + dirty = true this.set({ user, value: clone(value) }) - // vuexState.config.highlight[user]._migrated = 1 + vuexState.config.highlight[user]._migrated = 1 console.log(user, value, this.highlight[user]) } }) storage.setItem('vuex-lz', vuexState) - const userNew = userData.created_at > NEW_USER_DATE - let dirty = false - if (recent === null) { console.debug( `Data is empty, initializing for ${userNew ? 'new' : 'existing'} user`, From 9ddbd625f6bda9bf4144c41c0b203f26cec14a90 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 13 Mar 2026 12:13:32 +0200 Subject: [PATCH 2/3] fix console error --- src/stores/sync_config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 674f84f9a..244489074 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -413,7 +413,7 @@ export const _resetPrefs = ( return totalPrefs } -export const _doMigrations = async (data) => { +export const _doMigrations = async (data, setPreference) => { console.log('TEST', data._version) if (data._version < VERSION) { @@ -425,7 +425,7 @@ export const _doMigrations = async (data) => { // Migrate old config to sync config const vuexState = await storage.getItem('vuex-lz') defaultStateKeys.forEach(key => { - this.setPreference({ path: `simple.${key}`, value: vuexState.config[key] }) + setPreference({ path: `simple.${key}`, value: vuexState.config[key] }) }) } } @@ -636,8 +636,8 @@ export const useSyncConfigStore = defineStore('sync_config', { }) } - recent = recent && await _doMigrations(recent) - stale = stale && await _doMigrations(stale) + recent = recent && await _doMigrations(recent, this.setPreference) + stale = stale && await _doMigrations(stale, this.setPreference) if (!needUpload && recent && stale) { console.debug('Checking if data needs merging...') From 314dc3888ce0a2041bd7bba57e95bc6422ad4b4e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 13 Mar 2026 12:18:09 +0200 Subject: [PATCH 3/3] rename prefs to highlight, fix highlight journal replay --- src/stores/user_highlight.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/stores/user_highlight.js b/src/stores/user_highlight.js index d3456741f..14431b8b4 100644 --- a/src/stores/user_highlight.js +++ b/src/stores/user_highlight.js @@ -51,7 +51,7 @@ const _wrapData = (data, userName) => { const _checkValidity = (data) => data._timestamp > 0 -const _verifyPrefs = (state) => { +const _verifyHighlights = (state) => { state.highlight = state.highlight || {} // Simple @@ -148,7 +148,7 @@ const _mergeJournal = (...journals) => { ) } -export const _mergePrefs = (recent, stale) => { +export const _mergeHighlights = (recent, stale) => { if (!stale) return recent if (!recent) return stale const { _journal: recentJournal, ...recentData } = recent @@ -163,8 +163,8 @@ export const _mergePrefs = (recent, stale) => { * to requested one. Intended only to be used with simple preferences (boolean, number) */ const resultOutput = { ...recentData } - const totalJournal = _mergeJournal(staleJournal, recentJournal) - totalJournal.forEach(({ user, operation, args }) => { + const Journal = _mergeJournal(staleJournal, recentJournal) + Journal.forEach(({ user, operation, args }) => { if (user.startsWith('_')) { throw new Error( `journal contains entry to edit internal (starts with _) field '${user}', something is incorrect here, ignoring.`, @@ -172,16 +172,16 @@ export const _mergePrefs = (recent, stale) => { } switch (operation) { case 'set': - resultOutput.highlight[user] = args[0] + resultOutput[user] = args[0] break case 'unset': - delete resultOutput.highlight[user] + delete resultOutput[user] break default: return console.error(`Unknown journal operation: '${operation}'`) } }) - return { ...resultOutput, _journal: totalJournal } + return { ...resultOutput, _journal: Journal } } export const useUserHighlightStore = defineStore('user_highlight', { @@ -305,17 +305,17 @@ export const useUserHighlightStore = defineStore('user_highlight', { console.debug(`Data ${dirty ? 'needs' : "doesn't need"} merging`) } - let totalPrefs + let highlights if (dirty) { console.debug('Merging the data...') - _verifyPrefs(recent) - _verifyPrefs(stale) - totalPrefs = _mergePrefs(recent.highlight, stale.highlight) + _verifyHighlights(recent) + _verifyHighlights(stale) + highlights = _mergeHighlights(recent.highlight, stale.highlight) } else { - totalPrefs = recent.highlight + highlights = recent.highlight } - recent.highlight = { ...defaultState.highlight, ...totalPrefs } + recent.highlight = { ...defaultState.highlight, ...highlights } this.dirty = dirty || needUpload this.cache = recent