update tests, add journal trimming
This commit is contained in:
parent
45771001e6
commit
8ee71cdfff
5 changed files with 124 additions and 32 deletions
|
|
@ -3,8 +3,8 @@ import { mapState } from 'pinia'
|
|||
import Popover from '../popover/popover.vue'
|
||||
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons'
|
||||
|
|
|
|||
|
|
@ -93,7 +93,8 @@ const FilteringTab = {
|
|||
computed: {
|
||||
...SharedComputedObject(),
|
||||
...mapState(useSyncConfigStore, {
|
||||
muteFilters: (store) => Object.entries(store.prefsStorage.simple.muteFilters),
|
||||
muteFilters: (store) =>
|
||||
Object.entries(store.prefsStorage.simple.muteFilters),
|
||||
muteFiltersObject: (store) => store.prefsStorage.simple.muteFilters,
|
||||
}),
|
||||
...mapState(useInstanceCapabilitiesStore, ['blockExpiration']),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
groupBy,
|
||||
isEqual,
|
||||
set,
|
||||
take,
|
||||
takeRight,
|
||||
uniqWith,
|
||||
unset,
|
||||
|
|
@ -219,7 +220,7 @@ export const _mergeFlags = (recent, stale, allFlagKeys) => {
|
|||
)
|
||||
}
|
||||
|
||||
const _mergeJournal = (...journals) => {
|
||||
export const _mergeJournal = (...journals) => {
|
||||
// Ignore invalid journal entries
|
||||
const allJournals = flatten(
|
||||
journals.map((j) => (Array.isArray(j) ? j : [])),
|
||||
|
|
@ -267,9 +268,11 @@ const _mergeJournal = (...journals) => {
|
|||
return journal
|
||||
}
|
||||
})
|
||||
return flatten(trimmedGrouped).sort((a, b) =>
|
||||
|
||||
const flat = flatten(trimmedGrouped).sort((a, b) =>
|
||||
a.timestamp > b.timestamp ? 1 : -1,
|
||||
)
|
||||
return take(flat, 500)
|
||||
}
|
||||
|
||||
export const _mergePrefs = (recent, stale) => {
|
||||
|
|
@ -621,12 +624,26 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
const flagsTemplate = userNew ? newUserFlags : defaultState.flagStorage
|
||||
let dirty = false
|
||||
|
||||
if (recent === null) {
|
||||
console.debug(
|
||||
`Data is empty, initializing for ${userNew ? 'new' : 'existing'} user`,
|
||||
)
|
||||
recent = _wrapData({
|
||||
flagStorage: { ...flagsTemplate },
|
||||
prefsStorage: { ...defaultState.prefsStorage },
|
||||
})
|
||||
}
|
||||
|
||||
recent = recent && (await _doMigrations(recent, this.setPreference))
|
||||
stale = stale && (await _doMigrations(stale, this.setPreference))
|
||||
|
||||
// Various migrations
|
||||
console.debug('Migrating from old config')
|
||||
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||
vuexState.config = vuexState.config ?? {}
|
||||
|
||||
const migratedEntries = new Set(vuexState.config._syncMigration ?? [])
|
||||
console.debug(`Already migrated Values: ${[...migratedEntries].join()}`)
|
||||
console.debug(`Already migrated Values: ${[...migratedEntries].join() || '[none]'}`)
|
||||
|
||||
Object.entries(oldDefaultConfigSync).forEach(([key, value]) => {
|
||||
const oldValue = vuexState.config[key]
|
||||
|
|
@ -670,19 +687,6 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
vuexState.config._syncMigration = [...migratedEntries]
|
||||
storage.setItem('vuex-lz', vuexState)
|
||||
|
||||
if (recent === null) {
|
||||
console.debug(
|
||||
`Data is empty, initializing for ${userNew ? 'new' : 'existing'} user`,
|
||||
)
|
||||
recent = _wrapData({
|
||||
flagStorage: { ...flagsTemplate },
|
||||
prefsStorage: { ...defaultState.prefsStorage },
|
||||
})
|
||||
}
|
||||
|
||||
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...')
|
||||
// discarding timestamps and versions
|
||||
|
|
@ -722,6 +726,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
this.flagStorage = this.cache.flagStorage
|
||||
this.prefsStorage = this.cache.prefsStorage
|
||||
this.pushSyncConfig()
|
||||
console.log('C', this.cache)
|
||||
},
|
||||
pushSyncConfig({ force = false } = {}) {
|
||||
const needPush = this.dirty || force
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import 'virtual:pleroma-fe/service_worker_env'
|
|||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import { instanceDefaultConfig } from 'src/modules/default_config_state.js'
|
||||
import { parseNotification } from 'src/services/entity_normalizer/entity_normalizer.service.js'
|
||||
import { prepareNotificationObject } from 'src/services/notification_utils/notification_utils.js'
|
||||
import { cacheKey, emojiCacheKey, shouldCache } from 'src/services/sw/sw.js'
|
||||
import { instanceDefaultConfig } from 'src/modules/default_config_state.js'
|
||||
|
||||
// Collects all messages for service workers
|
||||
// Needed because service workers cannot use dynamic imports
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue