diff --git a/src/modules/old_default_config_state.js b/src/modules/old_default_config_state.js index 3977a5d89..dcb1da1fe 100644 --- a/src/modules/old_default_config_state.js +++ b/src/modules/old_default_config_state.js @@ -1,129 +1,129 @@ // this is a snapshot of config keys used prior to sync config. // used to migrate from old config. export const defaultStateKeys = [ - 'expertLevel', - 'hideISP', - 'hideInstanceWallpaper', - 'hideShoutbox', - 'hideMutedPosts', - 'hideMutedThreads', - 'hideWordFilteredPosts', - 'muteBotStatuses', - 'muteSensitiveStatuses', - 'collapseMessageWithSubject', - 'padEmoji', - 'hideAttachments', - 'hideAttachmentsInConv', - 'hideScrobbles', - 'hideScrobblesAfter', - 'maxThumbnails', - 'hideNsfw', - 'preloadImage', - 'loopVideo', - 'loopVideoSilentOnly', - 'streaming', - 'emojiReactionsOnTimeline', - 'alwaysShowNewPostButton', - 'autohideFloatingPostButton', - 'pauseOnUnfocused', - 'stopGifs', - 'replyVisibility', - 'thirdColumnMode', - 'notificationVisibility', - 'notificationNative', - 'webPushNotifications', - 'webPushAlwaysShowNotifications', - 'interfaceLanguage', - 'hideScopeNotice', - 'useStreamingApi', - 'sidebarRight', - 'scopeCopy', - 'subjectLineBehavior', - 'alwaysShowSubjectInput', - 'postContentType', - 'minimalScopesMode', - 'hideFilteredStatuses', - 'modalOnRepeat', - 'modalOnUnfollow', - 'modalOnBlock', - 'modalOnMute', - 'modalOnMuteConversation', - 'modalOnMuteDomain', - 'modalOnDelete', - 'modalOnLogout', - 'modalOnApproveFollow', - 'modalOnDenyFollow', - 'modalOnRemoveUserFromFollowers', - 'onMuteDefaultAction', - 'onBlockDefaultAction', - 'modalMobileCenter', - 'playVideosInModal', - 'useOneClickNsfw', - 'useContainFit', - 'disableStickyHeaders', - 'showScrollbars', - 'userPopoverAvatarAction', - 'userPopoverOverlay', - 'userCardLeftJustify', - 'userCardHidePersonalMarks', - 'sidebarColumnWidth', - 'contentColumnWidth', - 'notifsColumnWidth', - 'themeEditorMinWidth', - 'emojiReactionsScale', - 'textSize', - 'emojiSize', - 'navbarSize', - 'panelHeaderSize', - 'forcedRoundness', - 'navbarColumnStretch', - 'greentext', - 'mentionLinkDisplay', - 'mentionLinkShowTooltip', - 'mentionLinkShowAvatar', - 'mentionLinkFadeDomain', - 'mentionLinkShowYous', - 'mentionLinkBoldenYou', - 'hidePostStats', - 'hideBotIndication', - 'hideUserStats', - 'virtualScrolling', - 'sensitiveByDefault', - 'conversationDisplay', - 'conversationTreeAdvanced', - 'conversationOtherRepliesButton', - 'conversationTreeFadeAncestors', - 'showExtraNotifications', - 'showExtraNotificationsTip', - 'showChatsInExtraNotifications', - 'showAnnouncementsInExtraNotifications', - 'showFollowRequestsInExtraNotifications', - 'maxDepthInThread', - 'autocompleteSelect', - 'closingDrawerMarksAsSeen', - 'unseenAtTop', - 'ignoreInactionableSeen', - 'unsavedPostAction', - 'autoSaveDraft', - 'useAbsoluteTimeFormat', - 'absoluteTimeFormatMinAge', - 'absoluteTime12h', - 'imageCompression', - 'alwaysUseJpeg', - 'theme', +'expertLevel', +'hideISP', +'hideInstanceWallpaper', +'hideShoutbox', +'hideMutedPosts', +'hideMutedThreads', +'hideWordFilteredPosts', +'muteBotStatuses', +'muteSensitiveStatuses', +'collapseMessageWithSubject', +'padEmoji', +'hideAttachments', +'hideAttachmentsInConv', +'hideScrobbles', +'hideScrobblesAfter', +'maxThumbnails', +'hideNsfw', +'preloadImage', +'loopVideo', +'loopVideoSilentOnly', +'streaming', +'emojiReactionsOnTimeline', +'alwaysShowNewPostButton', +'autohideFloatingPostButton', +'pauseOnUnfocused', +'stopGifs', +'replyVisibility', +'thirdColumnMode', +'notificationVisibility', +'notificationNative', +'webPushNotifications', +'webPushAlwaysShowNotifications', +'interfaceLanguage', +'hideScopeNotice', +'useStreamingApi', +'sidebarRight', +'scopeCopy', +'subjectLineBehavior', +'alwaysShowSubjectInput', +'postContentType', +'minimalScopesMode', +'hideFilteredStatuses', +'modalOnRepeat', +'modalOnUnfollow', +'modalOnBlock', +'modalOnMute', +'modalOnMuteConversation', +'modalOnMuteDomain', +'modalOnDelete', +'modalOnLogout', +'modalOnApproveFollow', +'modalOnDenyFollow', +'modalOnRemoveUserFromFollowers', +'onMuteDefaultAction', +'onBlockDefaultAction', +'modalMobileCenter', +'playVideosInModal', +'useOneClickNsfw', +'useContainFit', +'disableStickyHeaders', +'showScrollbars', +'userPopoverAvatarAction', +'userPopoverOverlay', +'userCardLeftJustify', +'userCardHidePersonalMarks', +'sidebarColumnWidth', +'contentColumnWidth', +'notifsColumnWidth', +'themeEditorMinWidth', +'emojiReactionsScale', +'textSize', +'emojiSize', +'navbarSize', +'panelHeaderSize', +'forcedRoundness', +'navbarColumnStretch', +'greentext', +'mentionLinkDisplay', +'mentionLinkShowTooltip', +'mentionLinkShowAvatar', +'mentionLinkFadeDomain', +'mentionLinkShowYous', +'mentionLinkBoldenYou', +'hidePostStats', +'hideBotIndication', +'hideUserStats', +'virtualScrolling', +'sensitiveByDefault', +'conversationDisplay', +'conversationTreeAdvanced', +'conversationOtherRepliesButton', +'conversationTreeFadeAncestors', +'showExtraNotifications', +'showExtraNotificationsTip', +'showChatsInExtraNotifications', +'showAnnouncementsInExtraNotifications', +'showFollowRequestsInExtraNotifications', +'maxDepthInThread', +'autocompleteSelect', +'closingDrawerMarksAsSeen', +'unseenAtTop', +'ignoreInactionableSeen', +'unsavedPostAction', +'autoSaveDraft', +'useAbsoluteTimeFormat', +'absoluteTimeFormatMinAge', +'absoluteTime12h', +'imageCompression', +'alwaysUseJpeg', +'theme', - 'colors', +'colors', - 'customTheme', - 'customThemeSource', +'customTheme', +'customThemeSource', - 'style', - 'styleCustomData', - 'palette', - 'paletteCustomData', - 'themeDebug', - 'forceThemeRecompilation', - 'theme3hacks', - // 'muteWords', // mutes migrated separately - // 'highlight', // highlight migration is done separately +'style', +'styleCustomData', +'palette', +'paletteCustomData', +'themeDebug', +'forceThemeRecompilation', +'theme3hacks', +// 'muteWords', // mutes migrated separately +// 'highlight', // highlight migration is done separately ] diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index 648ca6ad7..d2e8d97e8 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -1,13 +1,12 @@ -import sum from 'hash-sum' import localforage from 'localforage' import { chunk, throttle } from 'lodash' import { getCssRules } from '../theme_data/css_utils.js' import { getEngineChecksum, init } from '../theme_data/theme_data_3.service.js' - -import { useSyncConfigStore } from 'src/stores/sync_config.js' +import sum from 'hash-sum' 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 // Otherwise it will return an array @@ -139,11 +138,9 @@ export const tryLoadCache = async () => { const cache = await localforage.getItem('pleromafe-theme-cache') if (!cache) return null try { - if ( - cache.engineChecksum === getEngineChecksum() && - cache.checksum !== undefined && - cache.checksum === useSyncConfigStore().mergedConfig.themeChecksum - ) { + if (cache.engineChecksum === getEngineChecksum() && + cache.checksum !== undefined && + cache.checksum === useSyncConfigStore().mergedConfig.themeChecksum) { const eagerStyles = createStyleSheet(EAGER_STYLE_ID, 10) const lazyStyles = createStyleSheet(LAZY_STYLE_ID, 20) @@ -209,10 +206,7 @@ export const applyTheme = ( engineChecksum: getEngineChecksum(), data, } - useSyncConfigStore().setSimplePrefAndSave({ - path: 'themeChecksum', - value: checksum, - }) + useSyncConfigStore().setSimplePrefAndSave({ path: 'themeChecksum', value: checksum }) onFinish(cache) localforage.setItem('pleromafe-theme-cache', cache) console.info('Theme cache stored') diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index c460b38b0..e56cf3210 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -20,9 +20,9 @@ import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/updat import { useInstanceStore } from 'src/stores/instance.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 { defaultStateKeys } from 'src/modules/old_default_config_state.js' +import { storage } from 'src/lib/storage.js' export const VERSION = 2 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) { // Migrate old config to sync config const vuexState = await storage.getItem('vuex-lz') - defaultStateKeys.forEach((key) => { + defaultStateKeys.forEach(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)) - stale = stale && (await _doMigrations(stale, this.setPreference)) + 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...') diff --git a/src/stores/user_highlight.js b/src/stores/user_highlight.js index c8868921a..96e54d80c 100644 --- a/src/stores/user_highlight.js +++ b/src/stores/user_highlight.js @@ -13,8 +13,8 @@ import { } from 'lodash' import { defineStore } from 'pinia' import { toRaw } from 'vue' - import { storage } from 'src/lib/storage.js' + 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 @@ -82,9 +82,7 @@ export const _getRecentData = (cache, live, isTest) => { result.recent = live result.stale = cache } 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) { console.debug( '[HIGHLIGHT] Same timestamp on both sources, source of truth irrelevant', @@ -286,9 +284,7 @@ export const useUserHighlightStore = defineStore('user_highlight', { needUpload = true this.set({ user, value: clone(value) }) 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) @@ -308,9 +304,7 @@ export const useUserHighlightStore = defineStore('user_highlight', { const { _timestamp: _0, ...recentData } = recent const { _timestamp: _2, ...staleData } = stale 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