diff --git a/src/components/font_control/font_control.js b/src/components/font_control/font_control.js index 81c46ec89..a66e1b88c 100644 --- a/src/components/font_control/font_control.js +++ b/src/components/font_control/font_control.js @@ -27,6 +27,7 @@ export default { }, emits: ['update:modelValue'], data() { + console.log(this.fallback) return { manualEntry: false, availableOptions: [ diff --git a/src/stores/instance.js b/src/stores/instance.js index 2923f3ad8..71ee05e7a 100644 --- a/src/stores/instance.js +++ b/src/stores/instance.js @@ -164,6 +164,7 @@ const DEFAULT_STATE = { ...LOCAL_DEFAULT_CONFIG, }, } +console.log('===', ROOT_STATE_DEFINITIONS) export const useInstanceStore = defineStore('instance', { state: () => ({ ...DEFAULT_STATE }), diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 7a5b1f4e1..9bce83a13 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -292,15 +292,12 @@ export const _mergePrefs = (recent, stale) => { const totalJournal = _mergeJournal(staleJournal, recentJournal) totalJournal .filter(({ path, operation, args }) => { - const entry = path.split('.')[1] - if (operation === 'unset') return ROOT_CONFIG[entry] !== undefined - const definition = path.startsWith('simple.muteFilters') ? { default: {} } - : ROOT_CONFIG_DEFINITIONS[entry] + : ROOT_CONFIG_DEFINITIONS[path.split('.')[1]] const finalValue = validateSetting({ - path: entry, + path: path.split('.')[1], value: args[0], definition, throwError: false, @@ -771,7 +768,7 @@ export const useSyncConfigStore = defineStore('sync_config', { }, persist: { afterLoad(state) { - console.debug('Validating persisted state of SyncConfig') + console.log('Validating persisted state of SyncConfig') const newState = { ...state } const newEntries = Object.entries(newState.prefsStorage.simple).map( ([path, value]) => { diff --git a/src/stores/user_highlight.js b/src/stores/user_highlight.js index ca61c6e4e..924fd4899 100644 --- a/src/stores/user_highlight.js +++ b/src/stores/user_highlight.js @@ -155,6 +155,7 @@ export const _mergeHighlights = (recent, stale) => { if (!recent) return stale const { _journal: recentJournal, ...recentHighlight } = recent const { _journal: staleJournal } = stale + console.log(recentHighlight) /** Journal entry format: * user: user to entry in highlight storage * timestamp: timestamp of the change @@ -332,6 +333,7 @@ export const useUserHighlightStore = defineStore('user_highlight', { if (stale && recent && !this.dirty) { this.cache._timestamp = Math.min(stale._timestamp, recent._timestamp) } + console.log('CACHE', this.cache) this.highlight = this.cache.highlight }, pushHighlight({ force = false } = {}) { diff --git a/test/unit/specs/stores/sync_config.spec.js b/test/unit/specs/stores/sync_config.spec.js index 9a582a193..adf447930 100644 --- a/test/unit/specs/stores/sync_config.spec.js +++ b/test/unit/specs/stores/sync_config.spec.js @@ -101,7 +101,7 @@ describe('The SyncConfig store', () => { const largeJournal = [] for (let value = 0; value < 1000; value++) { largeJournal.push({ - path: 'simple.palette' + value, + path: 'simple.testing' + value, operation: 'set', args: [value], // should have A timestamp, we don't really care what it is @@ -171,13 +171,13 @@ describe('The SyncConfig store', () => { store.pushSyncConfig = () => { /* no-op */ } - store.setPreference({ path: 'simple.palette', value: '1' }) - expect(store.prefsStorage.simple.palette).to.eql('1') + store.setPreference({ path: 'simple.testing', value: 1 }) + expect(store.prefsStorage.simple.testing).to.eql(1) expect(store.prefsStorage._journal.length).to.eql(1) expect(store.prefsStorage._journal[0]).to.eql({ - path: 'simple.palette', + path: 'simple.testing', operation: 'set', - args: ['1'], + args: [1], // should have A timestamp, we don't really care what it is timestamp: store.prefsStorage._journal[0].timestamp, }) @@ -189,26 +189,26 @@ describe('The SyncConfig store', () => { store.pushSyncConfig = () => { /* no-op */ } - store.setPreference({ path: 'simple.palette', value: 1 }) - store.setPreference({ path: 'simple.palette', value: 2 }) - store.addCollectionPreference({ path: 'collections.palette', value: 2 }) + store.setPreference({ path: 'simple.testing', value: 1 }) + store.setPreference({ path: 'simple.testing', value: 2 }) + store.addCollectionPreference({ path: 'collections.testing', value: 2 }) store.removeCollectionPreference({ - path: 'collections.palette', + path: 'collections.testing', value: 2, }) store.updateCache({ username: 'test' }) - expect(store.prefsStorage.simple.palette).to.eql(2) - expect(store.prefsStorage.collections.palette).to.eql([]) + expect(store.prefsStorage.simple.testing).to.eql(2) + expect(store.prefsStorage.collections.testing).to.eql([]) expect(store.prefsStorage._journal.length).to.eql(2) expect(store.prefsStorage._journal[0]).to.eql({ - path: 'simple.palette', + path: 'simple.testing', operation: 'set', args: [2], // should have A timestamp, we don't really care what it is timestamp: store.prefsStorage._journal[0].timestamp, }) expect(store.prefsStorage._journal[1]).to.eql({ - path: 'collections.palette', + path: 'collections.testing', operation: 'removeFromCollection', args: [2], // should have A timestamp, we don't really care what it is @@ -222,13 +222,13 @@ describe('The SyncConfig store', () => { store.pushSyncConfig = () => { /* no-op */ } - store.setPreference({ path: 'simple.palette', value: 1 }) - store.setPreference({ path: 'simple.palette', value: 1 }) - store.addCollectionPreference({ path: 'collections.palette', value: 2 }) - store.addCollectionPreference({ path: 'collections.palette', value: 2 }) + store.setPreference({ path: 'simple.testing', value: 1 }) + store.setPreference({ path: 'simple.testing', value: 1 }) + store.addCollectionPreference({ path: 'collections.testing', value: 2 }) + store.addCollectionPreference({ path: 'collections.testing', value: 2 }) store.updateCache({ username: 'test' }) - expect(store.prefsStorage.simple.palette).to.eql(1) - expect(store.prefsStorage.collections.palette).to.eql([2]) + expect(store.prefsStorage.simple.testing).to.eql(1) + expect(store.prefsStorage.collections.testing).to.eql([2]) expect(store.prefsStorage._journal.length).to.eql(2) }) @@ -238,10 +238,10 @@ describe('The SyncConfig store', () => { store.pushSyncConfig = () => { /* no-op */ } - store.setPreference({ path: 'simple.fontInput.family', value: 'test' }) - store.unsetPreference({ path: 'simple.fontInput.family' }) + store.setPreference({ path: 'simple.object.foo', value: 1 }) + store.unsetPreference({ path: 'simple.object.foo' }) store.updateCache(store, { username: 'test' }) - expect(store.prefsStorage.simple.fontInput).to.not.have.property('family') + expect(store.prefsStorage.simple.object).to.not.have.property('foo') expect(store.prefsStorage._journal.length).to.eql(1) }) @@ -393,11 +393,11 @@ describe('The SyncConfig store', () => { _mergePrefs( // RECENT { - simple: { theme: '1', style: '0', hideISP: true }, + simple: { a: 1, b: 0, c: true }, _journal: [ - { path: 'simple.style', operation: 'set', args: ['0'], timestamp: 2 }, + { path: 'simple.b', operation: 'set', args: [0], timestamp: 2 }, { - path: 'simple.hideISP', + path: 'simple.c', operation: 'set', args: [true], timestamp: 4, @@ -406,19 +406,19 @@ describe('The SyncConfig store', () => { }, // STALE { - simple: { theme: '1', style: '1', hideISP: false }, + simple: { a: 1, b: 1, c: false }, _journal: [ - { path: 'simple.theme', operation: 'set', args: ['1'], timestamp: 1 }, - { path: 'simple.style', operation: 'set', args: ['1'], timestamp: 3 }, + { path: 'simple.a', operation: 'set', args: [1], timestamp: 1 }, + { path: 'simple.b', operation: 'set', args: [1], timestamp: 3 }, ], }, ), ).to.eql({ - simple: { theme: '1', style: '1', hideISP: true }, + simple: { a: 1, b: 1, c: true }, _journal: [ - { path: 'simple.theme', operation: 'set', args: ['1'], timestamp: 1 }, - { path: 'simple.style', operation: 'set', args: ['1'], timestamp: 3 }, - { path: 'simple.hideISP', operation: 'set', args: [true], timestamp: 4 }, + { path: 'simple.a', operation: 'set', args: [1], timestamp: 1 }, + { path: 'simple.b', operation: 'set', args: [1], timestamp: 3 }, + { path: 'simple.c', operation: 'set', args: [true], timestamp: 4 }, ], }) }) @@ -428,11 +428,11 @@ describe('The SyncConfig store', () => { _mergePrefs( // RECENT { - simple: { theme: '1', style: '0', hideISP: false }, + simple: { a: 1, b: 0, c: false }, _journal: [ - { path: 'simple.style', operation: 'set', args: ['0'], timestamp: 2 }, + { path: 'simple.b', operation: 'set', args: [0], timestamp: 2 }, { - path: 'simple.hideISP', + path: 'simple.c', operation: 'set', args: [false], timestamp: 4, @@ -441,20 +441,19 @@ describe('The SyncConfig store', () => { }, // STALE { - simple: { theme: '0', style: '0', hideISP: true }, + simple: { a: 0, b: 0, c: true }, _journal: [ - { path: 'simple.theme', operation: 'set', args: ['0'], timestamp: 1 }, - { path: 'simple.style', operation: 'set', args: ['0'], timestamp: 3 }, + { path: 'simple.a', operation: 'set', args: [0], timestamp: 1 }, + { path: 'simple.b', operation: 'set', args: [0], timestamp: 3 }, ], }, ), ).to.eql({ simple: { a: 0, b: 0, c: false }, - simple: { theme: '0', style: '0', hideISP: false }, _journal: [ - { path: 'simple.theme', operation: 'set', args: ['0'], timestamp: 1 }, - { path: 'simple.style', operation: 'set', args: ['0'], timestamp: 3 }, - { path: 'simple.hideISP', operation: 'set', args: [false], timestamp: 4 }, + { path: 'simple.a', operation: 'set', args: [0], timestamp: 1 }, + { path: 'simple.b', operation: 'set', args: [0], timestamp: 3 }, + { path: 'simple.c', operation: 'set', args: [false], timestamp: 4 }, ], }) }) @@ -464,10 +463,10 @@ describe('The SyncConfig store', () => { _mergePrefs( // RECENT { - simple: { theme: 'foo' }, + simple: { a: 'foo' }, _journal: [ { - path: 'simple.theme', + path: 'simple.a', operation: 'set', args: ['foo'], timestamp: 2, @@ -476,10 +475,10 @@ describe('The SyncConfig store', () => { }, // STALE { - simple: { theme: 'bar' }, + simple: { a: 'bar' }, _journal: [ { - path: 'simple.theme', + path: 'simple.a', operation: 'set', args: ['bar'], timestamp: 4, @@ -488,9 +487,9 @@ describe('The SyncConfig store', () => { }, ), ).to.eql({ - simple: { theme: 'bar' }, + simple: { a: 'bar' }, _journal: [ - { path: 'simple.theme', operation: 'set', args: ['bar'], timestamp: 4 }, + { path: 'simple.a', operation: 'set', args: ['bar'], timestamp: 4 }, ], }) }) @@ -500,10 +499,10 @@ describe('The SyncConfig store', () => { _mergePrefs( // RECENT { - simple: { fontInput: { lv3: 'foo' } }, + simple: { lv2: { lv3: 'foo' } }, _journal: [ { - path: 'simple.fontInput.lv3', + path: 'simple.lv2.lv3', operation: 'set', args: ['foo'], timestamp: 2, @@ -512,10 +511,10 @@ describe('The SyncConfig store', () => { }, // STALE { - simple: { fontInput: { lv3: 'bar' } }, + simple: { lv2: { lv3: 'bar' } }, _journal: [ { - path: 'simple.fontInput.lv3', + path: 'simple.lv2.lv3', operation: 'set', args: ['bar'], timestamp: 4, @@ -524,10 +523,10 @@ describe('The SyncConfig store', () => { }, ), ).to.eql({ - simple: { fontInput: { lv3: 'bar' } }, + simple: { lv2: { lv3: 'bar' } }, _journal: [ { - path: 'simple.fontInput.lv3', + path: 'simple.lv2.lv3', operation: 'set', args: ['bar'], timestamp: 4, @@ -541,10 +540,10 @@ describe('The SyncConfig store', () => { _mergePrefs( // RECENT { - simple: { fontInput: { lv3: 'foo' } }, + simple: { lv2: { lv3: 'foo' } }, _journal: [ { - path: 'simple.fontInput.lv3', + path: 'simple.lv2.lv3', operation: 'set', args: ['foo'], timestamp: 2, @@ -553,10 +552,10 @@ describe('The SyncConfig store', () => { }, // STALE { - simple: { fontInput: {} }, + simple: { lv2: {} }, _journal: [ { - path: 'simple.fontInput.lv3', + path: 'simple.lv2.lv3', operation: 'unset', args: [], timestamp: 4, @@ -565,10 +564,10 @@ describe('The SyncConfig store', () => { }, ), ).to.eql({ - simple: { fontInput: {} }, + simple: { lv2: {} }, _journal: [ { - path: 'simple.fontInput.lv3', + path: 'simple.lv2.lv3', operation: 'unset', args: [], timestamp: 4,