highlight sync

This commit is contained in:
Henry Jameson 2026-03-13 11:52:15 +02:00
commit da49b0d009

View file

@ -12,6 +12,7 @@ import {
} from 'lodash' } from 'lodash'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { toRaw } from 'vue' import { toRaw } from 'vue'
import { storage } from 'src/lib/storage.js'
import { defaultState as configDefaultState } from 'src/modules/default_config_state' import { defaultState as configDefaultState } from 'src/modules/default_config_state'
@ -169,7 +170,6 @@ export const _mergePrefs = (recent, stale) => {
`journal contains entry to edit internal (starts with _) field '${user}', something is incorrect here, ignoring.`, `journal contains entry to edit internal (starts with _) field '${user}', something is incorrect here, ignoring.`,
) )
} }
console.log(resultOutput)
switch (operation) { switch (operation) {
case 'set': case 'set':
resultOutput.highlight[user] = args[0] resultOutput.highlight[user] = args[0]
@ -180,7 +180,6 @@ export const _mergePrefs = (recent, stale) => {
default: default:
return console.error(`Unknown journal operation: '${operation}'`) return console.error(`Unknown journal operation: '${operation}'`)
} }
console.log(resultOutput)
}) })
return { ...resultOutput, _journal: totalJournal } return { ...resultOutput, _journal: totalJournal }
} }
@ -219,9 +218,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
...oldValue, ...oldValue,
...value, ...value,
} }
console.log(oldValue, newValue, value)
this.highlight[user] = newValue this.highlight[user] = newValue
console.log(this.highlight)
this.highlight._journal = [ this.highlight._journal = [
...this.highlight._journal, ...this.highlight._journal,
{ operation: 'set', user, args: [newValue], timestamp: Date.now() }, { operation: 'set', user, args: [newValue], timestamp: Date.now() },
@ -262,7 +259,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
this.raw.highlight._journal = [] this.raw.highlight._journal = []
this.pushSyncConfig() this.pushSyncConfig()
}, },
initUserHighlight(userData) { async initUserHighlight(userData) {
const live = userData.user_highlight const live = userData.user_highlight
this.raw = live this.raw = live
let cache = this.cache let cache = this.cache
@ -275,6 +272,18 @@ export const useUserHighlightStore = defineStore('user_highlight', {
let { recent, stale, needUpload } = _getRecentData(cache, live) let { recent, stale, needUpload } = _getRecentData(cache, live)
const vuexState = await storage.getItem('vuex-lz')
const { highlight } = vuexState.config
Object.entries(highlight).forEach(([user, value]) => {
if ((highlight[user]._migrated || 0) < 1) {
vuexState.config.highlight[user]._migrated = 1
this.set({ user, value })
console.log(user, value, this.highlight[user])
}
})
storage.setItem('vuex-lz', vuexState)
this.pushHighlight()
const userNew = userData.created_at > NEW_USER_DATE const userNew = userData.created_at > NEW_USER_DATE
let dirty = false let dirty = false