Merge branch 'setttingssync' into shigusegubu-themes3
This commit is contained in:
commit
702e6b231c
4 changed files with 148 additions and 136 deletions
|
|
@ -1,129 +1,129 @@
|
||||||
// this is a snapshot of config keys used prior to sync config.
|
// this is a snapshot of config keys used prior to sync config.
|
||||||
// used to migrate from old config.
|
// used to migrate from old config.
|
||||||
export const defaultStateKeys = [
|
export const defaultStateKeys = [
|
||||||
'expertLevel',
|
'expertLevel',
|
||||||
'hideISP',
|
'hideISP',
|
||||||
'hideInstanceWallpaper',
|
'hideInstanceWallpaper',
|
||||||
'hideShoutbox',
|
'hideShoutbox',
|
||||||
'hideMutedPosts',
|
'hideMutedPosts',
|
||||||
'hideMutedThreads',
|
'hideMutedThreads',
|
||||||
'hideWordFilteredPosts',
|
'hideWordFilteredPosts',
|
||||||
'muteBotStatuses',
|
'muteBotStatuses',
|
||||||
'muteSensitiveStatuses',
|
'muteSensitiveStatuses',
|
||||||
'collapseMessageWithSubject',
|
'collapseMessageWithSubject',
|
||||||
'padEmoji',
|
'padEmoji',
|
||||||
'hideAttachments',
|
'hideAttachments',
|
||||||
'hideAttachmentsInConv',
|
'hideAttachmentsInConv',
|
||||||
'hideScrobbles',
|
'hideScrobbles',
|
||||||
'hideScrobblesAfter',
|
'hideScrobblesAfter',
|
||||||
'maxThumbnails',
|
'maxThumbnails',
|
||||||
'hideNsfw',
|
'hideNsfw',
|
||||||
'preloadImage',
|
'preloadImage',
|
||||||
'loopVideo',
|
'loopVideo',
|
||||||
'loopVideoSilentOnly',
|
'loopVideoSilentOnly',
|
||||||
'streaming',
|
'streaming',
|
||||||
'emojiReactionsOnTimeline',
|
'emojiReactionsOnTimeline',
|
||||||
'alwaysShowNewPostButton',
|
'alwaysShowNewPostButton',
|
||||||
'autohideFloatingPostButton',
|
'autohideFloatingPostButton',
|
||||||
'pauseOnUnfocused',
|
'pauseOnUnfocused',
|
||||||
'stopGifs',
|
'stopGifs',
|
||||||
'replyVisibility',
|
'replyVisibility',
|
||||||
'thirdColumnMode',
|
'thirdColumnMode',
|
||||||
'notificationVisibility',
|
'notificationVisibility',
|
||||||
'notificationNative',
|
'notificationNative',
|
||||||
'webPushNotifications',
|
'webPushNotifications',
|
||||||
'webPushAlwaysShowNotifications',
|
'webPushAlwaysShowNotifications',
|
||||||
'interfaceLanguage',
|
'interfaceLanguage',
|
||||||
'hideScopeNotice',
|
'hideScopeNotice',
|
||||||
'useStreamingApi',
|
'useStreamingApi',
|
||||||
'sidebarRight',
|
'sidebarRight',
|
||||||
'scopeCopy',
|
'scopeCopy',
|
||||||
'subjectLineBehavior',
|
'subjectLineBehavior',
|
||||||
'alwaysShowSubjectInput',
|
'alwaysShowSubjectInput',
|
||||||
'postContentType',
|
'postContentType',
|
||||||
'minimalScopesMode',
|
'minimalScopesMode',
|
||||||
'hideFilteredStatuses',
|
'hideFilteredStatuses',
|
||||||
'modalOnRepeat',
|
'modalOnRepeat',
|
||||||
'modalOnUnfollow',
|
'modalOnUnfollow',
|
||||||
'modalOnBlock',
|
'modalOnBlock',
|
||||||
'modalOnMute',
|
'modalOnMute',
|
||||||
'modalOnMuteConversation',
|
'modalOnMuteConversation',
|
||||||
'modalOnMuteDomain',
|
'modalOnMuteDomain',
|
||||||
'modalOnDelete',
|
'modalOnDelete',
|
||||||
'modalOnLogout',
|
'modalOnLogout',
|
||||||
'modalOnApproveFollow',
|
'modalOnApproveFollow',
|
||||||
'modalOnDenyFollow',
|
'modalOnDenyFollow',
|
||||||
'modalOnRemoveUserFromFollowers',
|
'modalOnRemoveUserFromFollowers',
|
||||||
'onMuteDefaultAction',
|
'onMuteDefaultAction',
|
||||||
'onBlockDefaultAction',
|
'onBlockDefaultAction',
|
||||||
'modalMobileCenter',
|
'modalMobileCenter',
|
||||||
'playVideosInModal',
|
'playVideosInModal',
|
||||||
'useOneClickNsfw',
|
'useOneClickNsfw',
|
||||||
'useContainFit',
|
'useContainFit',
|
||||||
'disableStickyHeaders',
|
'disableStickyHeaders',
|
||||||
'showScrollbars',
|
'showScrollbars',
|
||||||
'userPopoverAvatarAction',
|
'userPopoverAvatarAction',
|
||||||
'userPopoverOverlay',
|
'userPopoverOverlay',
|
||||||
'userCardLeftJustify',
|
'userCardLeftJustify',
|
||||||
'userCardHidePersonalMarks',
|
'userCardHidePersonalMarks',
|
||||||
'sidebarColumnWidth',
|
'sidebarColumnWidth',
|
||||||
'contentColumnWidth',
|
'contentColumnWidth',
|
||||||
'notifsColumnWidth',
|
'notifsColumnWidth',
|
||||||
'themeEditorMinWidth',
|
'themeEditorMinWidth',
|
||||||
'emojiReactionsScale',
|
'emojiReactionsScale',
|
||||||
'textSize',
|
'textSize',
|
||||||
'emojiSize',
|
'emojiSize',
|
||||||
'navbarSize',
|
'navbarSize',
|
||||||
'panelHeaderSize',
|
'panelHeaderSize',
|
||||||
'forcedRoundness',
|
'forcedRoundness',
|
||||||
'navbarColumnStretch',
|
'navbarColumnStretch',
|
||||||
'greentext',
|
'greentext',
|
||||||
'mentionLinkDisplay',
|
'mentionLinkDisplay',
|
||||||
'mentionLinkShowTooltip',
|
'mentionLinkShowTooltip',
|
||||||
'mentionLinkShowAvatar',
|
'mentionLinkShowAvatar',
|
||||||
'mentionLinkFadeDomain',
|
'mentionLinkFadeDomain',
|
||||||
'mentionLinkShowYous',
|
'mentionLinkShowYous',
|
||||||
'mentionLinkBoldenYou',
|
'mentionLinkBoldenYou',
|
||||||
'hidePostStats',
|
'hidePostStats',
|
||||||
'hideBotIndication',
|
'hideBotIndication',
|
||||||
'hideUserStats',
|
'hideUserStats',
|
||||||
'virtualScrolling',
|
'virtualScrolling',
|
||||||
'sensitiveByDefault',
|
'sensitiveByDefault',
|
||||||
'conversationDisplay',
|
'conversationDisplay',
|
||||||
'conversationTreeAdvanced',
|
'conversationTreeAdvanced',
|
||||||
'conversationOtherRepliesButton',
|
'conversationOtherRepliesButton',
|
||||||
'conversationTreeFadeAncestors',
|
'conversationTreeFadeAncestors',
|
||||||
'showExtraNotifications',
|
'showExtraNotifications',
|
||||||
'showExtraNotificationsTip',
|
'showExtraNotificationsTip',
|
||||||
'showChatsInExtraNotifications',
|
'showChatsInExtraNotifications',
|
||||||
'showAnnouncementsInExtraNotifications',
|
'showAnnouncementsInExtraNotifications',
|
||||||
'showFollowRequestsInExtraNotifications',
|
'showFollowRequestsInExtraNotifications',
|
||||||
'maxDepthInThread',
|
'maxDepthInThread',
|
||||||
'autocompleteSelect',
|
'autocompleteSelect',
|
||||||
'closingDrawerMarksAsSeen',
|
'closingDrawerMarksAsSeen',
|
||||||
'unseenAtTop',
|
'unseenAtTop',
|
||||||
'ignoreInactionableSeen',
|
'ignoreInactionableSeen',
|
||||||
'unsavedPostAction',
|
'unsavedPostAction',
|
||||||
'autoSaveDraft',
|
'autoSaveDraft',
|
||||||
'useAbsoluteTimeFormat',
|
'useAbsoluteTimeFormat',
|
||||||
'absoluteTimeFormatMinAge',
|
'absoluteTimeFormatMinAge',
|
||||||
'absoluteTime12h',
|
'absoluteTime12h',
|
||||||
'imageCompression',
|
'imageCompression',
|
||||||
'alwaysUseJpeg',
|
'alwaysUseJpeg',
|
||||||
'theme',
|
'theme',
|
||||||
|
|
||||||
'colors',
|
'colors',
|
||||||
|
|
||||||
'customTheme',
|
'customTheme',
|
||||||
'customThemeSource',
|
'customThemeSource',
|
||||||
|
|
||||||
'style',
|
'style',
|
||||||
'styleCustomData',
|
'styleCustomData',
|
||||||
'palette',
|
'palette',
|
||||||
'paletteCustomData',
|
'paletteCustomData',
|
||||||
'themeDebug',
|
'themeDebug',
|
||||||
'forceThemeRecompilation',
|
'forceThemeRecompilation',
|
||||||
'theme3hacks',
|
'theme3hacks',
|
||||||
// 'muteWords', // mutes migrated separately
|
// 'muteWords', // mutes migrated separately
|
||||||
// 'highlight', // highlight migration is done separately
|
// 'highlight', // highlight migration is done separately
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
|
import sum from 'hash-sum'
|
||||||
import localforage from 'localforage'
|
import localforage from 'localforage'
|
||||||
import { chunk, throttle } from 'lodash'
|
import { chunk, throttle } from 'lodash'
|
||||||
|
|
||||||
import { getCssRules } from '../theme_data/css_utils.js'
|
import { getCssRules } from '../theme_data/css_utils.js'
|
||||||
import { getEngineChecksum, init } from '../theme_data/theme_data_3.service.js'
|
import { getEngineChecksum, init } from '../theme_data/theme_data_3.service.js'
|
||||||
import sum from 'hash-sum'
|
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { defaultState } from 'src/modules/default_config_state.js'
|
import { defaultState } from 'src/modules/default_config_state.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
|
||||||
|
|
||||||
// On platforms where this is not supported, it will return undefined
|
// On platforms where this is not supported, it will return undefined
|
||||||
// Otherwise it will return an array
|
// Otherwise it will return an array
|
||||||
|
|
@ -138,9 +139,11 @@ export const tryLoadCache = async () => {
|
||||||
const cache = await localforage.getItem('pleromafe-theme-cache')
|
const cache = await localforage.getItem('pleromafe-theme-cache')
|
||||||
if (!cache) return null
|
if (!cache) return null
|
||||||
try {
|
try {
|
||||||
if (cache.engineChecksum === getEngineChecksum() &&
|
if (
|
||||||
cache.checksum !== undefined &&
|
cache.engineChecksum === getEngineChecksum() &&
|
||||||
cache.checksum === useSyncConfigStore().mergedConfig.themeChecksum) {
|
cache.checksum !== undefined &&
|
||||||
|
cache.checksum === useSyncConfigStore().mergedConfig.themeChecksum
|
||||||
|
) {
|
||||||
const eagerStyles = createStyleSheet(EAGER_STYLE_ID, 10)
|
const eagerStyles = createStyleSheet(EAGER_STYLE_ID, 10)
|
||||||
const lazyStyles = createStyleSheet(LAZY_STYLE_ID, 20)
|
const lazyStyles = createStyleSheet(LAZY_STYLE_ID, 20)
|
||||||
|
|
||||||
|
|
@ -206,7 +209,10 @@ export const applyTheme = (
|
||||||
engineChecksum: getEngineChecksum(),
|
engineChecksum: getEngineChecksum(),
|
||||||
data,
|
data,
|
||||||
}
|
}
|
||||||
useSyncConfigStore().setSimplePrefAndSave({ path: 'themeChecksum', value: checksum })
|
useSyncConfigStore().setSimplePrefAndSave({
|
||||||
|
path: 'themeChecksum',
|
||||||
|
value: checksum,
|
||||||
|
})
|
||||||
onFinish(cache)
|
onFinish(cache)
|
||||||
localforage.setItem('pleromafe-theme-cache', cache)
|
localforage.setItem('pleromafe-theme-cache', cache)
|
||||||
console.info('Theme cache stored')
|
console.info('Theme cache stored')
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/updat
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
|
||||||
|
import { storage } from 'src/lib/storage.js'
|
||||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state.js'
|
import { defaultState as configDefaultState } from 'src/modules/default_config_state.js'
|
||||||
import { defaultStateKeys } from 'src/modules/old_default_config_state.js'
|
import { defaultStateKeys } from 'src/modules/old_default_config_state.js'
|
||||||
import { storage } from 'src/lib/storage.js'
|
|
||||||
|
|
||||||
export const VERSION = 2
|
export const VERSION = 2
|
||||||
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
||||||
|
|
@ -421,7 +421,7 @@ export const _doMigrations = async (data, setPreference) => {
|
||||||
if (data._version === 1) {
|
if (data._version === 1) {
|
||||||
// Migrate old config to sync config
|
// Migrate old config to sync config
|
||||||
const vuexState = await storage.getItem('vuex-lz')
|
const vuexState = await storage.getItem('vuex-lz')
|
||||||
defaultStateKeys.forEach(key => {
|
defaultStateKeys.forEach((key) => {
|
||||||
setPreference({ path: `simple.${key}`, value: vuexState.config[key] })
|
setPreference({ path: `simple.${key}`, value: vuexState.config[key] })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -633,8 +633,8 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
recent = recent && await _doMigrations(recent, this.setPreference)
|
recent = recent && (await _doMigrations(recent, this.setPreference))
|
||||||
stale = stale && await _doMigrations(stale, this.setPreference)
|
stale = stale && (await _doMigrations(stale, this.setPreference))
|
||||||
|
|
||||||
if (!needUpload && recent && stale) {
|
if (!needUpload && recent && stale) {
|
||||||
console.debug('Checking if data needs merging...')
|
console.debug('Checking if data needs merging...')
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ 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 { 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'
|
||||||
|
|
||||||
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
||||||
|
|
@ -82,7 +82,9 @@ export const _getRecentData = (cache, live, isTest) => {
|
||||||
result.recent = live
|
result.recent = live
|
||||||
result.stale = cache
|
result.stale = cache
|
||||||
} else if (cacheValid && liveValid) {
|
} else if (cacheValid && liveValid) {
|
||||||
console.debug('[HIGHLIGHT] Both sources have valid data, figuring things out...')
|
console.debug(
|
||||||
|
'[HIGHLIGHT] Both sources have valid data, figuring things out...',
|
||||||
|
)
|
||||||
if (live._timestamp === cache._timestamp) {
|
if (live._timestamp === cache._timestamp) {
|
||||||
console.debug(
|
console.debug(
|
||||||
'[HIGHLIGHT] Same timestamp on both sources, source of truth irrelevant',
|
'[HIGHLIGHT] Same timestamp on both sources, source of truth irrelevant',
|
||||||
|
|
@ -284,7 +286,9 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
||||||
needUpload = true
|
needUpload = true
|
||||||
this.set({ user, value: clone(value) })
|
this.set({ user, value: clone(value) })
|
||||||
vuexState.config.highlight[user]._migrated = 1
|
vuexState.config.highlight[user]._migrated = 1
|
||||||
console.debug(`[HIGHLIGHT] Migrating user ${user}: ${ JSON.stringify(value) }`)
|
console.debug(
|
||||||
|
`[HIGHLIGHT] Migrating user ${user}: ${JSON.stringify(value)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
storage.setItem('vuex-lz', vuexState)
|
storage.setItem('vuex-lz', vuexState)
|
||||||
|
|
@ -304,7 +308,9 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
||||||
const { _timestamp: _0, ...recentData } = recent
|
const { _timestamp: _0, ...recentData } = recent
|
||||||
const { _timestamp: _2, ...staleData } = stale
|
const { _timestamp: _2, ...staleData } = stale
|
||||||
dirty = !isEqual(recentData, staleData)
|
dirty = !isEqual(recentData, staleData)
|
||||||
console.debug(`[HIGHLIGHT] Data ${dirty ? 'needs' : "doesn't need"} merging`)
|
console.debug(
|
||||||
|
`[HIGHLIGHT] Data ${dirty ? 'needs' : "doesn't need"} merging`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let highlights
|
let highlights
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue