diff --git a/package.json b/package.json
index 1d0382d46..20c01a0b3 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"ci-eslint": "yarn exec eslint",
"ci-stylelint": "yarn exec stylelint '**/*.scss' '**/*.vue'",
"lint": "yarn ci-biome; yarn ci-eslint; yarn ci-stylelint",
- "lint-fix": "yarn exec eslint -- --fix; yarn exec stylelint '**/*.scss' '**/*.vue' --fix; biome check --write"
+ "lint-fix": "yarn exec eslint --fix; yarn exec stylelint '**/*.scss' '**/*.vue' --fix; biome check --write"
},
"dependencies": {
"@babel/runtime": "7.28.4",
diff --git a/src/App.js b/src/App.js
index 0128fc198..6dcd80a73 100644
--- a/src/App.js
+++ b/src/App.js
@@ -26,7 +26,6 @@ import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { useShoutStore } from 'src/stores/shout.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
export default {
name: 'app',
@@ -73,7 +72,7 @@ export default {
},
created() {
// Load the locale from the storage
- const val = useSyncConfigStore().mergedConfig.interfaceLanguage
+ const val = this.$store.getters.mergedConfig.interfaceLanguage
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
document.getElementById('modal').classList = ['-' + this.layoutType]
@@ -123,7 +122,7 @@ export default {
]
},
navClasses() {
- const { navbarColumnStretch } = useSyncConfigStore().mergedConfig
+ const { navbarColumnStretch } = this.$store.getters.mergedConfig
return [
'-' + this.layoutType,
...(navbarColumnStretch ? ['-column-stretch'] : []),
@@ -158,19 +157,19 @@ export default {
if (this.isChats) return false
if (this.isListEdit) return false
return (
- useSyncConfigStore().mergedConfig.alwaysShowNewPostButton ||
+ this.$store.getters.mergedConfig.alwaysShowNewPostButton ||
this.layoutType === 'mobile'
)
},
shoutboxPosition() {
- return useSyncConfigStore().mergedConfig.alwaysShowNewPostButton || false
+ return this.$store.getters.mergedConfig.alwaysShowNewPostButton || false
},
hideShoutbox() {
- return useSyncConfigStore().mergedConfig.hideShoutbox
+ return this.$store.getters.mergedConfig.hideShoutbox
},
reverseLayout() {
const { thirdColumnMode, sidebarRight: reverseSetting } =
- useSyncConfigStore().mergedConfig
+ this.$store.getters.mergedConfig
if (this.layoutType !== 'wide') {
return reverseSetting
} else {
@@ -180,10 +179,10 @@ export default {
}
},
noSticky() {
- return useSyncConfigStore().mergedConfig.disableStickyHeaders
+ return this.$store.getters.mergedConfig.disableStickyHeaders
},
showScrollbars() {
- return useSyncConfigStore().mergedConfig.showScrollbars
+ return this.$store.getters.mergedConfig.showScrollbars
},
scrollParent() {
return window /* this.$refs.appContentRef */
@@ -191,7 +190,7 @@ export default {
showInstanceSpecificPanel() {
return (
this.instanceSpecificPanelPresent &&
- !useSyncConfigStore().mergedConfig.hideISP
+ !this.$store.getters.mergedConfig.hideISP
)
},
...mapGetters(['mergedConfig']),
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index 97f9b8a42..b7e97cf45 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -17,7 +17,7 @@ config.autoAddCss = false
import App from '../App.vue'
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import FaviconService from '../services/favicon_service/favicon_service.js'
-import { applyStyleConfig } from '../services/style_setter/style_setter.js'
+import { applyConfig } from '../services/style_setter/style_setter.js'
import { initServiceWorker, updateFocus } from '../services/sw/sw.js'
import {
windowHeight,
@@ -88,25 +88,25 @@ const getInstanceConfig = async ({ store }) => {
data.pleroma,
)
useInstanceStore().set({
- path: 'textlimit',
+ name: 'textlimit',
value: textlimit,
})
useInstanceStore().set({
- path: 'accountApprovalRequired',
+ name: 'accountApprovalRequired',
value: data.approval_required,
})
useInstanceStore().set({
- path: 'birthdayRequired',
+ name: 'birthdayRequired',
value: !!data.pleroma?.metadata.birthday_required,
})
useInstanceStore().set({
- path: 'birthdayMinAge',
+ name: 'birthdayMinAge',
value: data.pleroma?.metadata.birthday_min_age || 0,
})
if (vapidPublicKey) {
useInstanceStore().set({
- path: 'vapidPublicKey',
+ name: 'vapidPublicKey',
value: vapidPublicKey,
})
}
@@ -258,7 +258,7 @@ const getAppSecret = async ({ store }) => {
const resolveStaffAccounts = ({ store, accounts }) => {
const nicknames = accounts.map((uri) => uri.split('/').pop())
useInstanceStore().set({
- path: 'staffAccounts',
+ name: 'staffAccounts',
value: nicknames,
})
}
@@ -384,20 +384,20 @@ const getNodeInfo = async ({ store }) => {
const software = data.software
useInstanceStore().set({
- path: 'backendVersion',
+ name: 'backendVersion',
value: software.version,
})
useInstanceStore().set({
- path: 'backendRepository',
+ name: 'backendRepository',
value: software.repository,
})
const priv = metadata.private
- useInstanceStore().set({ path: 'privateMode', value: priv })
+ useInstanceStore().set({ name: 'privateMode', value: priv })
const frontendVersion = window.___pleromafe_commit_hash
useInstanceStore().set({
- path: 'frontendVersion',
+ name: 'frontendVersion',
value: frontendVersion,
})
@@ -547,7 +547,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
return Promise.reject(e)
}
- applyStyleConfig(store.state.config, i18n.global)
+ applyConfig(store.state.config, i18n.global)
// Now we can try getting the server settings and logging in
// Most of these are preloaded into the index.html so blocking is minimized
diff --git a/src/components/about/about.js b/src/components/about/about.js
index ab1ace320..f52d5c797 100644
--- a/src/components/about/about.js
+++ b/src/components/about/about.js
@@ -5,7 +5,6 @@ import StaffPanel from '../staff_panel/staff_panel.vue'
import TermsOfServicePanel from '../terms_of_service_panel/terms_of_service_panel.vue'
import { useInstanceStore } from 'src/stores/instance.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
const About = {
components: {
@@ -22,7 +21,7 @@ const About = {
showInstanceSpecificPanel() {
return (
useInstanceStore().instanceIdentity.showInstanceSpecificPanel &&
- !useSyncConfigStore().mergedConfig.hideISP &&
+ !this.$store.getters.mergedConfig.hideISP &&
useInstanceStore().instanceIdentity.instanceSpecificPanelContent
)
},
diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js
index 38f585675..8fce4b5af 100644
--- a/src/components/account_actions/account_actions.js
+++ b/src/components/account_actions/account_actions.js
@@ -8,7 +8,6 @@ import ProgressButton from '../progress_button/progress_button.vue'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useReportsStore } from 'src/stores/reports'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons'
@@ -90,10 +89,10 @@ const AccountActions = {
},
computed: {
shouldConfirmBlock() {
- return useSyncConfigStore().mergedConfig.modalOnBlock
+ return this.$store.getters.mergedConfig.modalOnBlock
},
shouldConfirmRemoveUserFromFollowers() {
- return useSyncConfigStore().mergedConfig.modalOnRemoveUserFromFollowers
+ return this.$store.getters.mergedConfig.modalOnRemoveUserFromFollowers
},
...mapState(useInstanceCapabilitiesStore, [
'blockExpiration',
diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js
index a67bd475e..db5171c80 100644
--- a/src/components/attachment/attachment.js
+++ b/src/components/attachment/attachment.js
@@ -9,7 +9,6 @@ import VideoAttachment from '../video_attachment/video_attachment.vue'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMediaViewerStore } from 'src/stores/media_viewer'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -59,8 +58,8 @@ const Attachment = {
localDescription: this.description || this.attachment.description,
nsfwImage:
useInstanceStore().instanceIdentity.nsfwCensorImage || nsfwImage,
- hideNsfwLocal: useSyncConfigStore().mergedConfig.hideNsfw,
- preloadImage: useSyncConfigStore().mergedConfig.preloadImage,
+ hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw,
+ preloadImage: this.$store.getters.mergedConfig.preloadImage,
loading: false,
img:
fileTypeService.fileType(this.attachment.mimetype) === 'image' &&
@@ -94,7 +93,7 @@ const Attachment = {
return this.size === 'hide'
},
useContainFit() {
- return useSyncConfigStore().mergedConfig.useContainFit
+ return this.$store.getters.mergedConfig.useContainFit
},
placeholderName() {
if (this.attachment.description === '' || !this.attachment.description) {
diff --git a/src/components/confirm_modal/mute_confirm.js b/src/components/confirm_modal/mute_confirm.js
index 888aa017b..c486ad7e4 100644
--- a/src/components/confirm_modal/mute_confirm.js
+++ b/src/components/confirm_modal/mute_confirm.js
@@ -1,10 +1,8 @@
-import { mapState } from 'pinia'
+import { mapGetters } from 'vuex'
import Select from 'src/components/select/select.vue'
import ConfirmModal from './confirm_modal.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
export default {
props: ['type', 'user', 'status'],
emits: ['hide', 'show', 'muted'],
@@ -45,7 +43,7 @@ export default {
}
}
},
- ...mapState(useSyncConfigStore, ['mergedConfig']),
+ ...mapGetters(['mergedConfig']),
},
methods: {
optionallyPrompt() {
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js
index 76dd26352..cb7cf4782 100644
--- a/src/components/conversation/conversation.js
+++ b/src/components/conversation/conversation.js
@@ -9,7 +9,6 @@ import Status from '../status/status.vue'
import ThreadTree from '../thread_tree/thread_tree.vue'
import { useInterfaceStore } from 'src/stores/interface'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -82,7 +81,7 @@ const conversation = {
// maxDepthInThread = max number of depths that is *visible*
// since our depth starts with 0 and "showing" means "showing children"
// there is a -2 here
- const maxDepth = useSyncConfigStore().mergedConfig.maxDepthInThread - 2
+ const maxDepth = this.$store.getters.mergedConfig.maxDepthInThread - 2
return maxDepth >= 1 ? maxDepth : 1
},
streamingEnabled() {
@@ -92,22 +91,22 @@ const conversation = {
)
},
displayStyle() {
- return useSyncConfigStore().mergedConfig.conversationDisplay
+ return this.$store.getters.mergedConfig.conversationDisplay
},
isTreeView() {
return !this.isLinearView
},
treeViewIsSimple() {
- return !useSyncConfigStore().mergedConfig.conversationTreeAdvanced
+ return !this.$store.getters.mergedConfig.conversationTreeAdvanced
},
isLinearView() {
return this.displayStyle === 'linear'
},
shouldFadeAncestors() {
- return useSyncConfigStore().mergedConfig.conversationTreeFadeAncestors
+ return this.$store.getters.mergedConfig.conversationTreeFadeAncestors
},
otherRepliesButtonPosition() {
- return useSyncConfigStore().mergedConfig.conversationOtherRepliesButton
+ return this.$store.getters.mergedConfig.conversationOtherRepliesButton
},
showOtherRepliesButtonBelowStatus() {
return this.otherRepliesButtonPosition === 'below'
diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js
index 0871e0bd3..943c66d1e 100644
--- a/src/components/desktop_nav/desktop_nav.js
+++ b/src/components/desktop_nav/desktop_nav.js
@@ -5,7 +5,6 @@ import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInterfaceStore } from 'src/stores/interface'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -97,7 +96,7 @@ export default {
return this.$store.state.users.currentUser
},
shouldConfirmLogout() {
- return useSyncConfigStore().mergedConfig.modalOnLogout
+ return this.$store.getters.mergedConfig.modalOnLogout
},
},
methods: {
diff --git a/src/components/dialog_modal/dialog_modal.js b/src/components/dialog_modal/dialog_modal.js
index e5c399086..8070d3429 100644
--- a/src/components/dialog_modal/dialog_modal.js
+++ b/src/components/dialog_modal/dialog_modal.js
@@ -1,5 +1,3 @@
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
const DialogModal = {
props: {
darkOverlay: {
@@ -15,7 +13,7 @@ const DialogModal = {
},
computed: {
mobileCenter() {
- return useSyncConfigStore().mergedConfig.modalMobileCenter
+ return this.$store.getters.mergedConfig.modalMobileCenter
},
},
}
diff --git a/src/components/draft/draft.js b/src/components/draft/draft.js
index 5ee85dff4..971a75b10 100644
--- a/src/components/draft/draft.js
+++ b/src/components/draft/draft.js
@@ -6,8 +6,6 @@ import Gallery from 'src/components/gallery/gallery.vue'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import StatusContent from 'src/components/status_content/status_content.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
import { library } from '@fortawesome/fontawesome-svg-core'
import { faPollH } from '@fortawesome/free-solid-svg-icons'
@@ -59,7 +57,7 @@ const Draft = {
: undefined
},
localCollapseSubjectDefault() {
- return useSyncConfigStore().mergedConfig.collapseMessageWithSubject
+ return this.$store.getters.mergedConfig.collapseMessageWithSubject
},
nsfwClickthrough() {
if (!this.draft.nsfw) {
diff --git a/src/components/draft_closer/draft_closer.js b/src/components/draft_closer/draft_closer.js
index 5f297bf4c..d724ab4ac 100644
--- a/src/components/draft_closer/draft_closer.js
+++ b/src/components/draft_closer/draft_closer.js
@@ -1,7 +1,5 @@
import DialogModal from 'src/components/dialog_modal/dialog_modal.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
const DraftCloser = {
data() {
return {
@@ -14,10 +12,10 @@ const DraftCloser = {
emits: ['save', 'discard'],
computed: {
action() {
- if (useSyncConfigStore().mergedConfig.autoSaveDraft) {
+ if (this.$store.getters.mergedConfig.autoSaveDraft) {
return 'save'
} else {
- return useSyncConfigStore().mergedConfig.unsavedPostAction
+ return this.$store.getters.mergedConfig.unsavedPostAction
}
},
shouldConfirm() {
diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js
index 4917a11fb..24794640e 100644
--- a/src/components/emoji_input/emoji_input.js
+++ b/src/components/emoji_input/emoji_input.js
@@ -2,16 +2,13 @@ import { take } from 'lodash'
import Popover from 'src/components/popover/popover.vue'
import ScreenReaderNotice from 'src/components/screen_reader_notice/screen_reader_notice.vue'
+import { ensureFinalFallback } from '../../i18n/languages.js'
import Completion from '../../services/completion/completion.js'
import { findOffset } from '../../services/offset_finder/offset_finder.service.js'
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import EmojiPicker from '../emoji_picker/emoji_picker.vue'
import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_indicator.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
-import { ensureFinalFallback } from 'src/i18n/languages.js'
-
import { library } from '@fortawesome/fontawesome-svg-core'
import { faSmileBeam } from '@fortawesome/free-regular-svg-icons'
@@ -134,10 +131,10 @@ const EmojiInput = {
},
computed: {
padEmoji() {
- return useSyncConfigStore().mergedConfig.padEmoji
+ return this.$store.getters.mergedConfig.padEmoji
},
defaultCandidateIndex() {
- return useSyncConfigStore().mergedConfig.autocompleteSelect ? 0 : -1
+ return this.$store.getters.mergedConfig.autocompleteSelect ? 0 : -1
},
preText() {
return this.modelValue.slice(0, this.caret)
@@ -166,7 +163,7 @@ const EmojiInput = {
},
languages() {
return ensureFinalFallback(
- useSyncConfigStore().mergedConfig.interfaceLanguage,
+ this.$store.getters.mergedConfig.interfaceLanguage,
)
},
maybeLocalizedEmojiNamesAndKeywords() {
@@ -334,6 +331,7 @@ const EmojiInput = {
if (!this.pickerShown) {
this.scrollIntoView()
this.$refs.picker.showPicker()
+ this.$refs.picker.startEmojiLoad()
} else {
this.$refs.picker.hidePicker()
}
diff --git a/src/components/emoji_input/suggestor.js b/src/components/emoji_input/suggestor.js
index c0d8f7ca1..c478fea67 100644
--- a/src/components/emoji_input/suggestor.js
+++ b/src/components/emoji_input/suggestor.js
@@ -1,5 +1,3 @@
-import { useEmojiStore } from 'src/stores/emoji.js'
-
/**
* suggest - generates a suggestor function to be used by emoji-input
* data: object providing source information for specific types of suggestions:
diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js
index 1e4594b2c..79c0ab47e 100644
--- a/src/components/emoji_picker/emoji_picker.js
+++ b/src/components/emoji_picker/emoji_picker.js
@@ -8,7 +8,6 @@ import StillImage from '../still-image/still-image.vue'
import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -341,7 +340,7 @@ const EmojiPicker = {
this.$nextTick(() => {
this.updateEmojiSize()
})
- return useSyncConfigStore().mergedConfig.fontSize
+ return this.$store.getters.mergedConfig.fontSize
},
emojiHeight() {
return this.emojiSize
@@ -406,7 +405,7 @@ const EmojiPicker = {
},
languages() {
return ensureFinalFallback(
- useSyncConfigStore().mergedConfig.interfaceLanguage,
+ this.$store.getters.mergedConfig.interfaceLanguage,
)
},
maybeLocalizedEmojiName() {
diff --git a/src/components/follow_button/follow_button.js b/src/components/follow_button/follow_button.js
index 539749bc8..eb545b28d 100644
--- a/src/components/follow_button/follow_button.js
+++ b/src/components/follow_button/follow_button.js
@@ -3,8 +3,6 @@ import {
requestUnfollow,
} from '../../services/follow_manipulate/follow_manipulate'
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
-
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
export default {
props: ['relationship', 'user', 'labelFollowing', 'buttonClass'],
components: {
@@ -18,7 +16,7 @@ export default {
},
computed: {
shouldConfirmUnfollow() {
- return useSyncConfigStore().mergedConfig.modalOnUnfollow
+ return this.$store.getters.mergedConfig.modalOnUnfollow
},
isPressed() {
return this.inProgress || this.relationship.following
diff --git a/src/components/follow_request_card/follow_request_card.js b/src/components/follow_request_card/follow_request_card.js
index b7959a2d3..c037ddf42 100644
--- a/src/components/follow_request_card/follow_request_card.js
+++ b/src/components/follow_request_card/follow_request_card.js
@@ -2,8 +2,6 @@ import { notificationsFromStore } from '../../services/notification_utils/notifi
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
const FollowRequestCard = {
props: ['user'],
components: {
@@ -78,7 +76,7 @@ const FollowRequestCard = {
},
computed: {
mergedConfig() {
- return useSyncConfigStore().mergedConfig
+ return this.$store.getters.mergedConfig
},
shouldConfirmApprove() {
return this.mergedConfig.modalOnApproveFollow
diff --git a/src/components/link-preview/link-preview.js b/src/components/link-preview/link-preview.js
index a465cc213..ac91f916d 100644
--- a/src/components/link-preview/link-preview.js
+++ b/src/components/link-preview/link-preview.js
@@ -1,6 +1,4 @@
-import { mapState } from 'pinia'
-
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { mapGetters } from 'vuex'
const LinkPreview = {
name: 'LinkPreview',
@@ -26,7 +24,7 @@ const LinkPreview = {
hideNsfwConfig() {
return this.mergedConfig.hideNsfw
},
- ...mapState(useSyncConfigStore, ['mergedConfig']),
+ ...mapGetters(['mergedConfig']),
},
created() {
if (this.useImage) {
diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js
index be62142c6..ee61fa369 100644
--- a/src/components/media_upload/media_upload.js
+++ b/src/components/media_upload/media_upload.js
@@ -2,7 +2,6 @@ import fileSizeFormatService from '../../services/file_size_format/file_size_for
import statusPosterService from '../../services/status_poster/status_poster.service.js'
import { useInstanceStore } from 'src/stores/instance.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faCircleNotch, faUpload } from '@fortawesome/free-solid-svg-icons'
@@ -34,7 +33,7 @@ const mediaUpload = {
}
// Skip if image compression is disabled
- if (!useSyncConfigStore().mergedConfig.imageCompression) {
+ if (!this.$store.getters.mergedConfig.imageCompression) {
return file
}
@@ -79,7 +78,7 @@ const mediaUpload = {
// Convert to WebP if supported and alwaysUseJpeg is false, otherwise JPEG
const type =
- !useSyncConfigStore().mergedConfig.alwaysUseJpeg && supportsWebP
+ !this.$store.getters.mergedConfig.alwaysUseJpeg && supportsWebP
? 'image/webp'
: 'image/jpeg'
const extension = type === 'image/webp' ? '.webp' : '.jpg'
diff --git a/src/components/mentions_line/mentions_line.js b/src/components/mentions_line/mentions_line.js
index bd3882866..e6aa392a0 100644
--- a/src/components/mentions_line/mentions_line.js
+++ b/src/components/mentions_line/mentions_line.js
@@ -1,9 +1,7 @@
-import { mapState } from 'pinia'
+import { mapGetters } from 'vuex'
import MentionLink from 'src/components/mention_link/mention_link.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
export const MENTIONS_LIMIT = 5
const MentionsLine = {
@@ -28,7 +26,7 @@ const MentionsLine = {
manyMentions() {
return this.extraMentions.length > 0
},
- ...mapState(useSyncConfigStore, ['mergedConfig']),
+ ...mapGetters(['mergedConfig']),
},
methods: {
toggleShowMore() {
diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js
index 6242344ce..c5b1d66f6 100644
--- a/src/components/mobile_nav/mobile_nav.js
+++ b/src/components/mobile_nav/mobile_nav.js
@@ -13,7 +13,7 @@ import SideDrawer from '../side_drawer/side_drawer.vue'
import { useAnnouncementsStore } from 'src/stores/announcements.js'
import { useInstanceStore } from 'src/stores/instance.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -75,15 +75,15 @@ const MobileNav = {
return this.$route.name === 'chat'
},
...mapState(useAnnouncementsStore, ['unreadAnnouncementCount']),
- ...mapState(useSyncConfigStore, {
+ ...mapState(useServerSideStorageStore, {
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems).has('chats'),
}),
shouldConfirmLogout() {
- return useSyncConfigStore().mergedConfig.modalOnLogout
+ return this.$store.getters.mergedConfig.modalOnLogout
},
closingDrawerMarksAsSeen() {
- return useSyncConfigStore().mergedConfig.closingDrawerMarksAsSeen
+ return this.$store.getters.mergedConfig.closingDrawerMarksAsSeen
},
...mapGetters(['unreadChatCount']),
},
diff --git a/src/components/mobile_post_status_button/mobile_post_status_button.js b/src/components/mobile_post_status_button/mobile_post_status_button.js
index 594cd6688..83103c827 100644
--- a/src/components/mobile_post_status_button/mobile_post_status_button.js
+++ b/src/components/mobile_post_status_button/mobile_post_status_button.js
@@ -1,7 +1,6 @@
import { debounce } from 'lodash'
import { usePostStatusStore } from 'src/stores/post_status.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faPen } from '@fortawesome/free-solid-svg-icons'
@@ -46,10 +45,10 @@ const MobilePostStatusButton = {
)
},
isPersistent() {
- return !!useSyncConfigStore().mergedConfig.alwaysShowNewPostButton
+ return !!this.$store.getters.mergedConfig.alwaysShowNewPostButton
},
autohideFloatingPostButton() {
- return !!useSyncConfigStore().mergedConfig.autohideFloatingPostButton
+ return !!this.$store.getters.mergedConfig.autohideFloatingPostButton
},
},
watch: {
diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js
index 9e5901f24..8aff31f02 100644
--- a/src/components/nav_panel/nav_panel.js
+++ b/src/components/nav_panel/nav_panel.js
@@ -12,7 +12,7 @@ import NavigationPins from 'src/components/navigation/navigation_pins.vue'
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -84,28 +84,28 @@ const NavPanel = {
this.editMode = !this.editMode
},
toggleCollapse() {
- useSyncConfigStore().setPreference({
+ useServerSideStorageStore().setPreference({
path: 'simple.collapseNav',
value: !this.collapsed,
})
- useSyncConfigStore().pushSyncConfig()
+ useServerSideStorageStore().pushServerSideStorage()
},
isPinned(item) {
return this.pinnedItems.has(item)
},
togglePin(item) {
if (this.isPinned(item)) {
- useSyncConfigStore().removeCollectionPreference({
+ useServerSideStorageStore().removeCollectionPreference({
path: 'collections.pinnedNavItems',
value: item,
})
} else {
- useSyncConfigStore().addCollectionPreference({
+ useServerSideStorageStore().addCollectionPreference({
path: 'collections.pinnedNavItems',
value: item,
})
}
- useSyncConfigStore().pushSyncConfig()
+ useServerSideStorageStore().pushServerSideStorage()
},
},
computed: {
@@ -122,7 +122,7 @@ const NavPanel = {
...mapPiniaState(useInstanceStore, {
privateMode: (store) => store.private,
}),
- ...mapPiniaState(useSyncConfigStore, {
+ ...mapPiniaState(useServerSideStorageStore, {
collapsed: (store) => store.prefsStorage.simple.collapseNav,
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js
index 7a43000ce..3384534be 100644
--- a/src/components/navigation/navigation_entry.js
+++ b/src/components/navigation/navigation_entry.js
@@ -5,7 +5,7 @@ import { routeTo } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
import { useAnnouncementsStore } from 'src/stores/announcements.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
@@ -23,17 +23,17 @@ const NavigationEntry = {
},
togglePin(value) {
if (this.isPinned(value)) {
- useSyncConfigStore().removeCollectionPreference({
+ useServerSideStorageStore().removeCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
} else {
- useSyncConfigStore().addCollectionPreference({
+ useServerSideStorageStore().addCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
}
- useSyncConfigStore().pushSyncConfig()
+ useServerSideStorageStore().pushServerSideStorage()
},
},
computed: {
@@ -47,7 +47,7 @@ const NavigationEntry = {
...mapState({
currentUser: (state) => state.users.currentUser,
}),
- ...mapPiniaState(useSyncConfigStore, {
+ ...mapPiniaState(useServerSideStorageStore, {
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
diff --git a/src/components/navigation/navigation_pins.js b/src/components/navigation/navigation_pins.js
index 85f6fafee..698bf5d59 100644
--- a/src/components/navigation/navigation_pins.js
+++ b/src/components/navigation/navigation_pins.js
@@ -18,7 +18,7 @@ import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useListsStore } from 'src/stores/lists'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
@@ -70,7 +70,7 @@ const NavPanel = {
...mapPiniaState(useBookmarkFoldersStore, {
bookmarks: getBookmarkFolderEntries,
}),
- ...mapPiniaState(useSyncConfigStore, {
+ ...mapPiniaState(useServerSideStorageStore, {
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js
index f3f5b76da..16084dee4 100644
--- a/src/components/notification/notification.js
+++ b/src/components/notification/notification.js
@@ -17,7 +17,6 @@ import UserLink from '../user_link/user_link.vue'
import UserPopover from '../user_popover/user_popover.vue'
import { useInstanceStore } from 'src/stores/instance.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
@@ -182,7 +181,7 @@ const Notification = {
return highlightClass(this.notification.from_profile)
},
userStyle() {
- const highlight = useSyncConfigStore().mergedConfig.highlight
+ const highlight = this.$store.getters.mergedConfig.highlight
const user = this.notification.from_profile
return highlightStyle(highlight[user.screen_name])
},
@@ -210,7 +209,7 @@ const Notification = {
return isStatusNotification(this.notification.type)
},
mergedConfig() {
- return useSyncConfigStore().mergedConfig
+ return this.$store.getters.mergedConfig
},
shouldConfirmApprove() {
return this.mergedConfig.modalOnApproveFollow
diff --git a/src/components/notifications/notification_filters.vue b/src/components/notifications/notification_filters.vue
index 5508e03ac..7be8eb76b 100644
--- a/src/components/notifications/notification_filters.vue
+++ b/src/components/notifications/notification_filters.vue
@@ -108,8 +108,6 @@
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index 4a27c468c..4616a4111 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -9,7 +9,6 @@ import Status from '../status/status.vue'
import TimelineMenu from '../timeline_menu/timeline_menu.vue'
import { useInterfaceStore } from 'src/stores/interface.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import timelineFetcher from 'src/services/timeline_fetcher/timeline_fetcher.service.js'
@@ -126,7 +125,7 @@ const Timeline = {
return this.timeline.visibleStatuses.slice(min, max).map((_) => _.id)
},
virtualScrollingEnabled() {
- return useSyncConfigStore().mergedConfig.virtualScrolling
+ return this.$store.getters.mergedConfig.virtualScrolling
},
...mapState(useInterfaceStore, {
mobileLayout: (store) => store.layoutType === 'mobile',
@@ -314,7 +313,7 @@ const Timeline = {
},
watch: {
newStatusCount(count) {
- if (!useSyncConfigStore().mergedConfig.streaming) {
+ if (!this.$store.getters.mergedConfig.streaming) {
return
}
if (count > 0) {
@@ -324,9 +323,7 @@ const Timeline = {
if (
top < 15 &&
!this.paused &&
- !(
- this.unfocused && useSyncConfigStore().mergedConfig.pauseOnUnfocused
- )
+ !(this.unfocused && this.$store.getters.mergedConfig.pauseOnUnfocused)
) {
this.showNewStatuses()
} else {
diff --git a/src/components/update_notification/update_notification.js b/src/components/update_notification/update_notification.js
index 78aaa79e8..a8bc60676 100644
--- a/src/components/update_notification/update_notification.js
+++ b/src/components/update_notification/update_notification.js
@@ -1,7 +1,7 @@
import Modal from 'src/components/modal/modal.vue'
import { useInstanceStore } from 'src/stores/instance.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage.js'
import pleromaTanFoxMask from 'src/assets/pleromatan_apology_fox_mask.png'
import pleromaTanMask from 'src/assets/pleromatan_apology_mask.png'
@@ -41,9 +41,9 @@ const UpdateNotification = {
return (
!useInstanceStore().disableUpdateNotification &&
this.$store.state.users.currentUser &&
- useSyncConfigStore().flagStorage.updateCounter <
+ useServerSideStorageStore().flagStorage.updateCounter <
CURRENT_UPDATE_COUNTER &&
- !useSyncConfigStore().prefsStorage.simple.dontShowUpdateNotifs
+ !useServerSideStorageStore().prefsStorage.simple.dontShowUpdateNotifs
)
},
},
@@ -53,22 +53,22 @@ const UpdateNotification = {
},
neverShowAgain() {
this.toggleShow()
- useSyncConfigStore().setFlag({
+ useServerSideStorageStore().setFlag({
flag: 'updateCounter',
value: CURRENT_UPDATE_COUNTER,
})
- useSyncConfigStore().setPreference({
+ useServerSideStorageStore().setPreference({
path: 'simple.dontShowUpdateNotifs',
value: true,
})
- useSyncConfigStore().pushSyncConfig()
+ useServerSideStorageStore().pushServerSideStorage()
},
dismiss() {
- useSyncConfigStore().setFlag({
+ useServerSideStorageStore().setFlag({
flag: 'updateCounter',
value: CURRENT_UPDATE_COUNTER,
})
- useSyncConfigStore().pushSyncConfig()
+ useServerSideStorageStore().pushServerSideStorage()
},
},
mounted() {
diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js
index b94a9ab9a..0df27e6cb 100644
--- a/src/components/user_card/user_card.js
+++ b/src/components/user_card/user_card.js
@@ -27,7 +27,6 @@ import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { usePostStatusStore } from 'src/stores/post_status'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { propsToNative } from 'src/services/attributes_helper/attributes_helper.service.js'
import localeService from 'src/services/locale/locale.service.js'
@@ -224,12 +223,12 @@ export default {
userHighlightType: {
get() {
const data =
- useSyncConfigStore().mergedConfig.highlight[this.user.screen_name]
+ this.$store.getters.mergedConfig.highlight[this.user.screen_name]
return (data && data.type) || 'disabled'
},
set(type) {
const data =
- useSyncConfigStore().mergedConfig.highlight[this.user.screen_name]
+ this.$store.getters.mergedConfig.highlight[this.user.screen_name]
if (type !== 'disabled') {
this.$store.dispatch('setHighlight', {
user: this.user.screen_name,
@@ -248,7 +247,7 @@ export default {
userHighlightColor: {
get() {
const data =
- useSyncConfigStore().mergedConfig.highlight[this.user.screen_name]
+ this.$store.getters.mergedConfig.highlight[this.user.screen_name]
return data && data.color
},
set(color) {
diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue
index 111b6b999..66529f59b 100644
--- a/src/components/user_card/user_card.vue
+++ b/src/components/user_card/user_card.vue
@@ -293,7 +293,7 @@
@@ -505,11 +505,11 @@
class="user-extras"
>
- {{ user.statuses_count }}
diff --git a/src/components/user_popover/user_popover.js b/src/components/user_popover/user_popover.js
index 8134f29e1..6d83aaa21 100644
--- a/src/components/user_popover/user_popover.js
+++ b/src/components/user_popover/user_popover.js
@@ -1,10 +1,7 @@
-import { mapState } from 'pinia'
import { defineAsyncComponent } from 'vue'
import UserCard from '../user_card/user_card.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
const UserPopover = {
name: 'UserPopover',
props: ['userId', 'overlayCenters', 'disabled', 'overlayCentersSelector'],
@@ -12,11 +9,14 @@ const UserPopover = {
UserCard,
Popover: defineAsyncComponent(() => import('../popover/popover.vue')),
},
- computed: mapState(useSyncConfigStore, {
- userPopoverAvatarAction: (state) =>
- state.mergedConfig.userPopoverAvatarAction,
- userPopoverOverlay: (state) => state.mergedConfig.userPopoverOverlay,
- }),
+ computed: {
+ userPopoverAvatarAction() {
+ return this.$store.getters.mergedConfig.userPopoverAvatarAction
+ },
+ userPopoverOverlay() {
+ return this.$store.getters.mergedConfig.userPopoverOverlay
+ },
+ },
}
export default UserPopover
diff --git a/src/components/user_timed_filter_modal/user_timed_filter_modal.js b/src/components/user_timed_filter_modal/user_timed_filter_modal.js
index a06c5db59..6c005ab4b 100644
--- a/src/components/user_timed_filter_modal/user_timed_filter_modal.js
+++ b/src/components/user_timed_filter_modal/user_timed_filter_modal.js
@@ -2,15 +2,13 @@ import Checkbox from 'src/components/checkbox/checkbox.vue'
import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue'
import Select from 'src/components/select/select.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
import { durationStrToMs } from 'src/services/date_utils/date_utils.js'
const UserTimedFilterModal = {
data() {
const action = this.isMute
- ? useSyncConfigStore().mergedConfig.onMuteDefaultAction
- : useSyncConfigStore().mergedConfig.onBlockDefaultAction
+ ? this.$store.getters.mergedConfig.onMuteDefaultAction
+ : this.$store.getters.mergedConfig.onBlockDefaultAction
const doAsk = action === 'ask'
const defaultValues = {}
@@ -46,9 +44,9 @@ const UserTimedFilterModal = {
computed: {
shouldConfirm() {
if (this.isMute) {
- return useSyncConfigStore().mergedConfig.onMuteDefaultAction === 'ask'
+ return this.$store.getters.mergedConfig.onMuteDefaultAction === 'ask'
} else {
- return useSyncConfigStore().mergedConfig.onBlockDefaultAction === 'ask'
+ return this.$store.getters.mergedConfig.onBlockDefaultAction === 'ask'
}
},
expiryString() {
diff --git a/src/components/video_attachment/video_attachment.js b/src/components/video_attachment/video_attachment.js
index 1feb1b9fa..92e915da8 100644
--- a/src/components/video_attachment/video_attachment.js
+++ b/src/components/video_attachment/video_attachment.js
@@ -1,5 +1,3 @@
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
const VideoAttachment = {
props: ['attachment', 'controls'],
data() {
@@ -11,10 +9,10 @@ const VideoAttachment = {
},
computed: {
loopVideo() {
- if (useSyncConfigStore().mergedConfig.loopVideoSilentOnly) {
+ if (this.$store.getters.mergedConfig.loopVideoSilentOnly) {
return !this.hasAudio
}
- return useSyncConfigStore().mergedConfig.loopVideo
+ return this.$store.getters.mergedConfig.loopVideo
},
},
methods: {
diff --git a/src/components/who_to_follow/who_to_follow.js b/src/components/who_to_follow/who_to_follow.js
index 720b15041..d90d626eb 100644
--- a/src/components/who_to_follow/who_to_follow.js
+++ b/src/components/who_to_follow/who_to_follow.js
@@ -1,8 +1,6 @@
import apiService from '../../services/api/api.service.js'
import FollowCard from '../follow_card/follow_card.vue'
-import { useInstanceStore } from 'src/stores/instance.js'
-
const WhoToFollow = {
components: {
FollowCard,
diff --git a/src/lib/language.js b/src/lib/language.js
deleted file mode 100644
index f8904dd07..000000000
--- a/src/lib/language.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import { useI18nStore } from 'src/stores/i18n.js'
-
-export const piniaLanguagePlugin = ({ store, options }) => {
- if (store.$id === 'sync_config') {
- store.$onAction(({ name, args }) => {
- if (name === 'setPreference') {
- const { path, value } = args[0]
- if (path === 'simple.interfaceLanguage') {
- useI18nStore().setLanguage(value)
- }
- }
- })
- }
-}
diff --git a/src/lib/push_notifications_plugin.js b/src/lib/push_notifications_plugin.js
index 0dfe9588b..9732a82c9 100644
--- a/src/lib/push_notifications_plugin.js
+++ b/src/lib/push_notifications_plugin.js
@@ -1,96 +1,37 @@
import { useInstanceStore } from 'src/stores/instance.js'
import { useInterfaceStore } from 'src/stores/interface.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-export const piniaPushNotificationsPlugin = ({ store }) => {
- if (
- store.$id !== 'sync_config' &&
- store.$id !== 'instance' &&
- store.$id !== 'interface'
- )
- return
-
- store.$onAction(({ name: actionName, args }) => {
- if (
- store.$id === 'interface' &&
- actionName !== 'setNotificationPermission' &&
- actionName !== 'setLoginStatus'
- )
- return
-
- // Initial state
- let vapidPublicKey = useInstanceStore().vapidPublicKey
- let enabled = useSyncConfigStore().mergedConfig.webPushNotifications
- let permissionGranted =
- useInterfaceStore().notificationPermission === 'granted'
- let permissionPresent =
- useInterfaceStore().notificationPermission !== undefined
- let user = !!window.vuex.state.users.currentUser
-
- if (store.$id === 'instance') {
- if (actionName === 'set' && args[0].path === 'vapidPublicKey') {
- const { value } = args[0]
- vapidPublicKey = value
- }
- }
-
- if (!vapidPublicKey || !permissionPresent) {
- return
- }
-
- if (store.$id === 'interface') {
- if (actionName === 'setNotificationPermission') {
- permissionGranted = args[0] === 'granted'
- } else if (actionName === 'setLoginStatus') {
- user = args[0]
- } else {
- return
- }
- } else if (store.$id === 'sync_config') {
- if (
- actionName === 'setPreference' &&
- args[0].path === 'simple.webPushNotifications'
- ) {
- const { value } = args[0]
- enabled = value
- } else {
- return
- }
- }
-
- if (permissionGranted && enabled && user) {
- console.log('piniaReg')
- return window.vuex.dispatch('registerPushNotifications')
- } else {
- console.log('piniaUnreg')
- return window.vuex.dispatch('unregisterPushNotifications')
- }
- })
-}
-
-export const vuexPushNotificationsPlugin = (store) => {
+export default (store) => {
store.subscribe((mutation, state) => {
- // Initial state
const vapidPublicKey = useInstanceStore().vapidPublicKey
- const enabled = useSyncConfigStore().mergedConfig.webPushNotifications
- const permissionGranted =
- useInterfaceStore().notificationPermission === 'granted'
- const permissionPresent =
- useInterfaceStore().notificationPermission !== undefined
+ const webPushNotification = state.config.webPushNotifications
+ const permission = useInterfaceStore().notificationPermission === 'granted'
const user = state.users.currentUser
- if (!permissionPresent || !vapidPublicKey) return
+ const isUserMutation = mutation.type === 'setCurrentUser'
+ const isVapidMutation =
+ mutation.type === 'setInstanceOption' &&
+ mutation.payload.name === 'vapidPublicKey'
+ const isPermMutation =
+ mutation.type === 'setNotificationPermission' &&
+ mutation.payload === 'granted'
+ const isUserConfigMutation =
+ mutation.type === 'setOption' &&
+ mutation.payload.name === 'webPushNotifications'
+ const isVisibilityMutation =
+ mutation.type === 'setOption' &&
+ mutation.payload.name === 'notificationVisibility'
if (
- mutation.type === 'setCurrentUser' ||
- mutation.type === 'clearCurrentUser'
+ isUserMutation ||
+ isVapidMutation ||
+ isPermMutation ||
+ isUserConfigMutation ||
+ isVisibilityMutation
) {
- console.log(!!user, permissionGranted, enabled)
- if (user && permissionGranted && enabled) {
- console.log('vuexReg')
+ if (user && vapidPublicKey && permission && webPushNotification) {
return store.dispatch('registerPushNotifications')
- } else {
- console.log('vuexUnreg')
+ } else if (isUserConfigMutation && !webPushNotification) {
return store.dispatch('unregisterPushNotifications')
}
}
diff --git a/src/lib/style.js b/src/lib/style.js
deleted file mode 100644
index 96603925a..000000000
--- a/src/lib/style.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import { applyStyleConfig } from 'src/services/style_setter/style_setter.js'
-
-const APPEARANCE_SETTINGS_KEYS = new Set(
- [
- 'sidebarColumnWidth',
- 'contentColumnWidth',
- 'notifsColumnWidth',
- 'themeEditorMinWidth',
- 'textSize',
- 'navbarSize',
- 'panelHeaderSize',
- 'forcedRoundness',
- 'emojiSize',
- 'emojiReactionsScale',
- ].map((x) => 'simple.' + x),
-)
-
-export const piniaStylePlugin = ({ store, options }) => {
- if (store.$id === 'sync_config') {
- store.$onAction(({ name, args, after }) => {
- if (name === 'setPreference') {
- const { path } = args[0]
- if (APPEARANCE_SETTINGS_KEYS.has(path)) {
- after(() => applyStyleConfig(store.mergedConfig))
- }
- }
- })
- }
-}
diff --git a/src/main.js b/src/main.js
index a4269b4a7..91653973d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -20,15 +20,9 @@ import messages from './i18n/messages.js'
import createPersistedState, {
piniaPersistPlugin,
} from './lib/persisted_state.js'
-import {
- piniaPushNotificationsPlugin,
- vuexPushNotificationsPlugin,
-} from './lib/push_notifications_plugin.js'
+import pushNotifications from './lib/push_notifications_plugin.js'
import vuexModules from './modules/index.js'
-import { piniaLanguagePlugin } from 'src/lib/language.js'
-import { piniaStylePlugin } from 'src/lib/style.js'
-
const currentLocale = (window.navigator.language || 'en').split('-')[0]
const i18n = createI18n({
@@ -41,7 +35,7 @@ const i18n = createI18n({
messages.setLanguage(i18n.global, currentLocale)
const persistedStateOptions = {
- paths: ['syncConfig.cache', 'config', 'users.lastLoginName', 'oauth'],
+ paths: ['serverSideStorage.cache', 'config', 'users.lastLoginName', 'oauth'],
}
;(async () => {
@@ -72,12 +66,9 @@ const persistedStateOptions = {
try {
let storageError
- const plugins = [vuexPushNotificationsPlugin]
+ const plugins = [pushNotifications]
const pinia = createPinia()
pinia.use(piniaPersistPlugin())
- pinia.use(piniaLanguagePlugin)
- pinia.use(piniaStylePlugin)
- pinia.use(piniaPushNotificationsPlugin)
try {
const persistedState = await createPersistedState(persistedStateOptions)
diff --git a/src/modules/config.js b/src/modules/config.js
index b68d547df..82acf8162 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -3,7 +3,7 @@ import { set } from 'lodash'
import messages from '../i18n/messages'
import localeService from '../services/locale/locale.service.js'
-import { applyStyleConfig } from '../services/style_setter/style_setter.js'
+import { applyConfig } from '../services/style_setter/style_setter.js'
import { defaultState, instanceDefaultConfig } from './default_config_state.js'
import { useEmojiStore } from 'src/stores/emoji.js'
@@ -71,7 +71,7 @@ const config = {
mutations: {
setOptionTemporarily(state, { name, value }) {
set(state, name, value)
- applyStyleConfig(state)
+ applyConfig(state)
},
setOption(state, { name, value }) {
set(state, name, value)
@@ -162,7 +162,7 @@ const config = {
} else {
commit('setOption', { name, value })
if (APPEARANCE_SETTINGS_KEYS.has(name)) {
- applyStyleConfig(state)
+ applyConfig(state)
}
if (name.startsWith('theme3hacks')) {
dispatch('applyTheme', { recompile: true })
diff --git a/src/modules/default_config_state.js b/src/modules/default_config_state.js
index 2f18fe9a5..3e39fb1fc 100644
--- a/src/modules/default_config_state.js
+++ b/src/modules/default_config_state.js
@@ -1,10 +1,9 @@
-const browserLocale = (navigator.language || 'en').split('-')[0]
+const browserLocale = (window.navigator.language || 'en').split('-')[0]
/// Instance config entries provided by static config or pleroma api
/// Put settings here only if it does not make sense for a normal user
/// to override it.
export const staticOrApiConfigDefault = {
- name: 'PleromaFE',
theme: 'pleroma-dark',
palette: null,
style: null,
diff --git a/src/modules/notifications.js b/src/modules/notifications.js
index 9507177a2..cb3d430db 100644
--- a/src/modules/notifications.js
+++ b/src/modules/notifications.js
@@ -10,7 +10,7 @@ import {
} from '../services/notification_utils/notification_utils.js'
import { useReportsStore } from 'src/stores/reports.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage.js'
const emptyNotifications = () => ({
desktopNotificationSilence: true,
@@ -119,7 +119,9 @@ export const notifications = {
maybeShowNotification(
store,
- Object.values(useSyncConfigStore().prefsStorage.simple.muteFilters),
+ Object.values(
+ useServerSideStorageStore().prefsStorage.simple.muteFilters,
+ ),
notification,
)
} else if (notification.seen) {
diff --git a/src/modules/users.js b/src/modules/users.js
index ea2a0ccb4..b0febcd3a 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -26,7 +26,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { useOAuthStore } from 'src/stores/oauth.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
+import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
import { declarations } from 'src/modules/config_declaration'
@@ -682,7 +682,7 @@ const users = {
useInterfaceStore().setLastTimeline('public-timeline')
useInterfaceStore().setLayoutWidth(windowWidth())
useInterfaceStore().setLayoutHeight(windowHeight())
- //useSyncConfigStore().clearSyncConfig()
+ store.commit('clearServerSideStorage')
})
},
loginUser(store, accessToken) {
@@ -702,7 +702,7 @@ const users = {
user.domainMutes = []
commit('setCurrentUser', user)
- useSyncConfigStore().setSyncConfig(user)
+ useServerSideStorageStore().setServerSideStorage(user)
commit('addNewUsers', [user])
useEmojiStore().fetchEmoji()
@@ -723,16 +723,17 @@ const users = {
/*
// Reset wordfilter
Object.keys(
- useSyncConfigStore().prefsStorage.simple.muteFilters
+ useServerSideStorageStore().prefsStorage.simple.muteFilters
).forEach(key => {
- useSyncConfigStore().unsetPreference({ path: 'simple.muteFilters.' + key, value: null })
+ useServerSideStorageStore().unsetPreference({ path: 'simple.muteFilters.' + key, value: null })
})
// Reset flag to 0 to re-run migrations
- useSyncConfigStore().setFlag({ flag: 'configMigration', value: 0 })
+ useServerSideStorageStore().setFlag({ flag: 'configMigration', value: 0 })
/**/
- const { configMigration } = useSyncConfigStore().flagStorage
+ const { configMigration } =
+ useServerSideStorageStore().flagStorage
declarations
.filter((x) => {
return (
@@ -743,12 +744,12 @@ const users = {
})
.toSorted((a, b) => a.configMigration - b.configMigration)
.forEach((value) => {
- value.migration(useSyncConfigStore(), store.rootState)
- useSyncConfigStore().setFlag({
+ value.migration(useServerSideStorageStore(), store.rootState)
+ useServerSideStorageStore().setFlag({
flag: 'configMigration',
value: value.migrationNum,
})
- useSyncConfigStore().pushSyncConfig()
+ useServerSideStorageStore().pushServerSideStorage()
})
if (user.token) {
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 48f8b9e8a..90886b4c5 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -318,7 +318,9 @@ const updateProfileJSON = ({ credentials, params }) => {
credentials,
payload: params,
method: 'PATCH',
- }).then((data) => parseUser(data))
+ })
+ .then((data) => data.json())
+ .then((data) => parseUser(data))
}
// Params needed:
diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js
index 495070b0d..08034d485 100644
--- a/src/services/style_setter/style_setter.js
+++ b/src/services/style_setter/style_setter.js
@@ -255,7 +255,7 @@ const extractStyleConfig = ({
const defaultStyleConfig = extractStyleConfig(defaultState)
-export const applyStyleConfig = (input) => {
+export const applyConfig = (input) => {
const config = extractStyleConfig(input)
if (config === defaultStyleConfig) {
diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js
index e744e37aa..72d78384c 100644
--- a/src/services/sw/sw.js
+++ b/src/services/sw/sw.js
@@ -41,7 +41,7 @@ function subscribePush(registration, isEnabled, vapidPublicKey) {
function unsubscribePush(registration) {
return registration.pushManager.getSubscription().then((subscription) => {
if (subscription === null) {
- return Promise.resolve('No subscription')
+ return
}
return subscription.unsubscribe()
})
@@ -158,23 +158,23 @@ export function registerPushNotifications(
export function unregisterPushNotifications(token) {
if (isPushSupported()) {
- getOrCreateServiceWorker()
- .then((registration) => {
- return unsubscribePush(registration).then((result) => [
- registration,
- result,
- ])
- })
- .then(([, unsubResult]) => {
- if (unsubResult === 'No subscription') return
- if (!unsubResult) {
- console.warn("Push subscription cancellation wasn't successful")
- }
- return deleteSubscriptionFromBackEnd(token)
- })
- .catch((e) => {
- console.warn(`Failed to disable Web Push Notifications: ${e.message}`)
- })
+ Promise.all([
+ deleteSubscriptionFromBackEnd(token),
+ getOrCreateServiceWorker()
+ .then((registration) => {
+ return unsubscribePush(registration).then((result) => [
+ registration,
+ result,
+ ])
+ })
+ .then(([, unsubResult]) => {
+ if (!unsubResult) {
+ console.warn("Push subscription cancellation wasn't successful")
+ }
+ }),
+ ]).catch((e) =>
+ console.warn(`Failed to disable Web Push Notifications: ${e.message}`),
+ )
}
}
diff --git a/src/stores/i18n.js b/src/stores/i18n.js
index a18b1d4d2..4e7c7c5d3 100644
--- a/src/stores/i18n.js
+++ b/src/stores/i18n.js
@@ -1,14 +1,5 @@
-import Cookies from 'js-cookie'
import { defineStore } from 'pinia'
-import { useEmojiStore } from 'src/stores/emoji.js'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
-import messages from 'src/i18n/messages'
-import localeService from 'src/services/locale/locale.service.js'
-
-const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
-
export const useI18nStore = defineStore('i18n', {
state: () => ({
i18n: null,
@@ -19,16 +10,5 @@ export const useI18nStore = defineStore('i18n', {
i18n: newI18n.global,
})
},
- setLanguage(originalValue) {
- const value =
- originalValue || useSyncConfigStore().mergedConfig.interfaceLanguage
-
- messages.setLanguage(this.i18n, value)
- useEmojiStore().loadUnicodeEmojiData(value)
- Cookies.set(
- BACKEND_LANGUAGE_COOKIE_NAME,
- localeService.internalToBackendLocaleMulti(value),
- )
- },
},
})
diff --git a/src/stores/sync_config.js b/src/stores/serverSideStorage.js
similarity index 87%
rename from src/stores/sync_config.js
rename to src/stores/serverSideStorage.js
index 009ccbce4..99f5045f7 100644
--- a/src/stores/sync_config.js
+++ b/src/stores/serverSideStorage.js
@@ -17,11 +17,7 @@ import { toRaw } from 'vue'
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
-import { useInstanceStore } from 'src/stores/instance'
-
-import { defaultState as configDefaultState } from 'src/modules/default_config_state'
-
-export const VERSION = 2
+export const VERSION = 1
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
export const COMMAND_TRIM_FLAGS = 1000
@@ -45,7 +41,6 @@ export const defaultState = {
dontShowUpdateNotifs: false,
collapseNav: false,
muteFilters: {},
- ...configDefaultState,
},
collections: {
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],
@@ -133,13 +128,13 @@ export const _getRecentData = (cache, live, isTest) => {
live._version === cache._version
) {
console.debug(
- 'Same version/timestamp on both sources, source of truth irrelevant',
+ 'Same version/timestamp on both source, source of truth irrelevant',
)
result.recent = cache
result.stale = live
} else {
console.debug(
- 'Different timestamp or version, figuring out which one is more recent',
+ 'Different timestamp, figuring out which one is more recent',
)
if (live._timestamp < cache._timestamp) {
result.recent = cache
@@ -213,7 +208,7 @@ const _mergeJournal = (...journals) => {
// side effect
journal.sort((a, b) => (a.timestamp > b.timestamp ? 1 : -1))
- if (path.startsWith('collections') || path.startsWith('objectCollection')) {
+ if (path.startsWith('collections')) {
const lastRemoveIndex = findLastIndex(
journal,
({ operation }) => operation === 'removeFromCollection',
@@ -234,7 +229,6 @@ const _mergeJournal = (...journals) => {
return false
}
if (a.operation === 'addToCollection') {
- // TODO check how objectCollections behaves here
return a.args[0] === b.args[0]
}
return false
@@ -374,21 +368,21 @@ export const _resetFlags = (
return result
}
-export const _doMigrations = (cache, live) => {
- const data = cache ?? live
+export const _doMigrations = (cache) => {
+ if (!cache) return cache
- if (data._version < VERSION) {
+ if (cache._version < VERSION) {
console.debug(
- 'Data has older version, seeing if there any migrations that can be applied',
+ 'Local cached data has older version, seeing if there any migrations that can be applied',
)
// no migrations right now since we only have one version
console.debug('No migrations found')
}
- if (data._version > VERSION) {
+ if (cache._version > VERSION) {
console.debug(
- 'Data has newer version, seeing if there any reverse migrations that can be applied',
+ 'Local cached data has newer version, seeing if there any reverse migrations that can be applied',
)
// no reverse migrations right now but we leave a possibility of loading a hotpatch if need be
@@ -397,9 +391,9 @@ export const _doMigrations = (cache, live) => {
console.debug('Found hotpatch migration, applying')
return window._PLEROMA_HOTPATCH.reverseMigrations.call(
{},
- 'syncConfigStore',
- { from: data._version, to: VERSION },
- data,
+ 'serverSideStorage',
+ { from: cache._version, to: VERSION },
+ cache,
)
}
}
@@ -408,7 +402,7 @@ export const _doMigrations = (cache, live) => {
return cache
}
-export const useSyncConfigStore = defineStore('sync_config', {
+export const useServerSideStorageStore = defineStore('serverSideStorage', {
state() {
return cloneDeep(defaultState)
},
@@ -516,40 +510,19 @@ export const useSyncConfigStore = defineStore('sync_config', {
`tried to edit internal (starts with _) field '${path}', ignoring.`,
)
}
-
- const { _key } = value
- if (path.startsWith('collection')) {
- const collection = new Set(get(this.prefsStorage, path))
- collection.delete(value)
- set(this.prefsStorage, path, [...collection])
-
- this.prefsStorage._journal = [
- ...this.prefsStorage._journal,
- {
- operation: 'removeFromCollection',
- path,
- args: [value],
- timestamp: Date.now(),
- },
- ]
- this.dirty = true
- } else if (path.startsWith('objectCollection')) {
- const collection = new Set(get(this.prefsStorage, path + '.index'))
- collection.delete(_key)
- set(this.prefsStorage, path + '.index', [...collection])
- const data = get(this.prefsStorage, path + '.data')
- delete data[_key]
-
- this.prefsStorage._journal = [
- ...this.prefsStorage._journal,
- {
- operation: 'removeFromCollection',
- path,
- args: [{ _key }],
- timestamp: Date.now(),
- },
- ]
- }
+ const collection = new Set(get(this.prefsStorage, path))
+ collection.delete(value)
+ set(this.prefsStorage, path, [...collection])
+ this.prefsStorage._journal = [
+ ...this.prefsStorage._journal,
+ {
+ operation: 'removeFromCollection',
+ path,
+ args: [value],
+ timestamp: Date.now(),
+ },
+ ]
+ this.dirty = true
},
reorderCollectionPreference({ path, value, movement }) {
if (path.startsWith('_')) {
@@ -581,23 +554,24 @@ export const useSyncConfigStore = defineStore('sync_config', {
username,
)
},
- clearSyncConfig() {
+ clearServerSideStorage() {
const blankState = { ...cloneDeep(defaultState) }
Object.keys(this).forEach((k) => {
this[k] = blankState[k]
})
},
- setSyncConfig(userData) {
+ setServerSideStorage(userData) {
const live = userData.storage
this.raw = live
let cache = this.cache
- if (cache?._user !== userData.fqn) {
+ if (cache && cache._user !== userData.fqn) {
console.warn(
'Cache belongs to another user! reinitializing local cache!',
)
cache = null
}
- console.log(cache, live)
+
+ cache = _doMigrations(cache)
let { recent, stale, needUpload } = _getRecentData(cache, live)
@@ -615,9 +589,6 @@ export const useSyncConfigStore = defineStore('sync_config', {
})
}
- recent = recent && _doMigrations(recent)
- stale = stale && _doMigrations(stale)
-
if (!needUpload && recent && stale) {
console.debug('Checking if data needs merging...')
// discarding timestamps and versions
@@ -656,7 +627,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
this.flagStorage = this.cache.flagStorage
this.prefsStorage = this.cache.prefsStorage
},
- pushSyncConfig({ force = false } = {}) {
+ pushServerSideStorage({ force = false } = {}) {
const needPush = this.dirty || force
if (!needPush) return
this.updateCache({ username: window.vuex.state.users.currentUser.fqn })
@@ -664,26 +635,9 @@ export const useSyncConfigStore = defineStore('sync_config', {
window.vuex.state.api.backendInteractor
.updateProfileJSON({ params })
.then((user) => {
- this.setSyncConfig(user)
+ this.setServerSideStorage(user)
this.dirty = false
})
},
},
- getters: {
- mergedConfig: (state) => {
- const instancePrefs = useInstanceStore().prefsStorage
- const result = Object.fromEntries(
- Object.entries(state.prefsStorage.simple).map(([k, v]) => [
- k,
- v ?? instancePrefs[k],
- ]),
- )
- return result
- },
- },
- persist: {
- afterLoad(state) {
- return state
- },
- },
})
diff --git a/test/unit/specs/boot/routes.spec.js b/test/unit/specs/boot/routes.spec.js
index f4be28a65..8795ea04e 100644
--- a/test/unit/specs/boot/routes.spec.js
+++ b/test/unit/specs/boot/routes.spec.js
@@ -1,7 +1,5 @@
import { createTestingPinia } from '@pinia/testing'
-
-createTestingPinia()
-
+ createTestingPinia()
import { createMemoryHistory, createRouter } from 'vue-router'
import { createStore } from 'vuex'
diff --git a/test/unit/specs/components/draft.spec.js b/test/unit/specs/components/draft.spec.js
index 7bc053f52..eb35cb58f 100644
--- a/test/unit/specs/components/draft.spec.js
+++ b/test/unit/specs/components/draft.spec.js
@@ -1,6 +1,6 @@
-import { createTestingPinia } from '@pinia/testing'
import { flushPromises, mount } from '@vue/test-utils'
import { nextTick } from 'vue'
+import { createTestingPinia } from '@pinia/testing'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
diff --git a/test/unit/specs/components/emoji_input.spec.js b/test/unit/specs/components/emoji_input.spec.js
index 62f90caa4..83ffd13d2 100644
--- a/test/unit/specs/components/emoji_input.spec.js
+++ b/test/unit/specs/components/emoji_input.spec.js
@@ -1,19 +1,23 @@
-import { createTestingPinia } from '@pinia/testing'
import { shallowMount } from '@vue/test-utils'
import vClickOutside from 'click-outside-vue3'
import { h } from 'vue'
-
-createTestingPinia()
+import { createTestingPinia } from '@pinia/testing'
+ createTestingPinia()
import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
const generateInput = (value, padEmoji = true) => {
const wrapper = shallowMount(EmojiInput, {
global: {
renderStubDefaultSlot: true,
mocks: {
+ $store: {
+ getters: {
+ mergedConfig: {
+ padEmoji,
+ },
+ },
+ },
$t: (msg) => msg,
},
stubs: {
@@ -44,12 +48,6 @@ const generateInput = (value, padEmoji = true) => {
}
describe('EmojiInput', () => {
- beforeEach(() => {
- const store = useSyncConfigStore(createTestingPinia())
- store.mergedConfig = {
- padEmoji: true,
- }
- })
describe('insertion mechanism', () => {
it('inserts string at the end with trailing space', () => {
const initialString = 'Testing'
@@ -113,10 +111,6 @@ describe('EmojiInput', () => {
it('inserts string without any padding if padEmoji setting is set to false', () => {
const initialString = 'Eat some spam!'
const wrapper = generateInput(initialString, false)
- const store = useSyncConfigStore(createTestingPinia())
- store.mergedConfig = {
- padEmoji: false,
- }
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length, keepOpen: false })
@@ -152,10 +146,6 @@ describe('EmojiInput', () => {
it('correctly sets caret after insertion if padEmoji setting is set to false', async () => {
const initialString = '1234'
const wrapper = generateInput(initialString, false)
- const store = useSyncConfigStore(createTestingPinia())
- store.mergedConfig = {
- padEmoji: false,
- }
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length })
diff --git a/test/unit/specs/stores/sync_config.spec.js b/test/unit/specs/modules/serverSideStorage.spec.js
similarity index 87%
rename from test/unit/specs/stores/sync_config.spec.js
rename to test/unit/specs/modules/serverSideStorage.spec.js
index abcddbeb1..bd2028ea3 100644
--- a/test/unit/specs/stores/sync_config.spec.js
+++ b/test/unit/specs/modules/serverSideStorage.spec.js
@@ -12,25 +12,25 @@ import {
COMMAND_TRIM_FLAGS_AND_RESET,
defaultState,
newUserFlags,
- useSyncConfigStore,
+ useServerSideStorageStore,
VERSION,
-} from 'src/stores/sync_config.js'
+} from 'src/stores/serverSideStorage.js'
-describe('The SyncConfig module', () => {
+describe('The serverSideStorage module', () => {
beforeEach(() => {
setActivePinia(createPinia())
})
describe('mutations', () => {
- describe('setSyncConfig', () => {
+ describe('setServerSideStorage', () => {
const user = {
created_at: new Date('1999-02-09'),
storage: {},
}
it('should initialize storage if none present', () => {
- const store = useSyncConfigStore()
- store.setSyncConfig({ ...user })
+ const store = useServerSideStorageStore()
+ store.setServerSideStorage(store, user)
expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number')
expect(store.cache.flagStorage).to.eql(defaultState.flagStorage)
@@ -38,8 +38,8 @@ describe('The SyncConfig module', () => {
})
it('should initialize storage with proper flags for new users if none present', () => {
- const store = useSyncConfigStore()
- store.setSyncConfig({ ...user, created_at: new Date() })
+ const store = useServerSideStorageStore()
+ store.setServerSideStorage({ ...user, created_at: new Date() })
expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number')
expect(store.cache.flagStorage).to.eql(newUserFlags)
@@ -47,14 +47,14 @@ describe('The SyncConfig module', () => {
})
it('should merge flags even if remote timestamp is older', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.cache = {
_timestamp: Date.now(),
_version: VERSION,
...cloneDeep(defaultState),
}
- store.setSyncConfig({
+ store.setServerSideStorage({
...user,
storage: {
_timestamp: 123,
@@ -76,10 +76,10 @@ describe('The SyncConfig module', () => {
})
it('should reset local timestamp to remote if contents are the same', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.cache = null
- store.setSyncConfig({
+ store.setServerSideStorage({
...user,
storage: {
_timestamp: 123,
@@ -95,9 +95,9 @@ describe('The SyncConfig module', () => {
expect(store.cache.flagStorage.updateCounter).to.eql(999)
})
- it('should use remote version if local missing', () => {
- const store = useSyncConfigStore()
- store.setSyncConfig(store, user)
+ it('should remote version if local missing', () => {
+ const store = useServerSideStorageStore()
+ store.setServerSideStorage(store, user)
expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number')
expect(store.cache.flagStorage).to.eql(defaultState.flagStorage)
@@ -105,7 +105,7 @@ describe('The SyncConfig module', () => {
})
describe('setPreference', () => {
it('should set preference and update journal log accordingly', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.setPreference({ path: 'simple.testing', value: 1 })
expect(store.prefsStorage.simple.testing).to.eql(1)
expect(store.prefsStorage._journal.length).to.eql(1)
@@ -119,34 +119,18 @@ describe('The SyncConfig module', () => {
})
it('should keep journal to a minimum', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.setPreference({ path: 'simple.testing', value: 1 })
store.setPreference({ path: 'simple.testing', value: 2 })
store.addCollectionPreference({ path: 'collections.testing', value: 2 })
- store.addCollectionPreference({
- path: 'objectCollections.testing',
- value: { _key: 'a', foo: 1 },
- })
- expect(store.prefsStorage.objectCollections.testing).to.eql({
- data: { a: { _key: 'a', foo: 1 } },
- index: ['a'],
- })
store.removeCollectionPreference({
path: 'collections.testing',
value: 2,
})
- store.removeCollectionPreference({
- path: 'objectCollections.testing',
- value: { _key: 'a' },
- })
store.updateCache({ username: 'test' })
expect(store.prefsStorage.simple.testing).to.eql(2)
expect(store.prefsStorage.collections.testing).to.eql([])
- expect(store.prefsStorage.objectCollections.testing).to.eql({
- data: {},
- index: [],
- })
- expect(store.prefsStorage._journal.length).to.eql(3)
+ expect(store.prefsStorage._journal.length).to.eql(2)
expect(store.prefsStorage._journal[0]).to.eql({
path: 'simple.testing',
operation: 'set',
@@ -161,41 +145,22 @@ describe('The SyncConfig module', () => {
// should have A timestamp, we don't really care what it is
timestamp: store.prefsStorage._journal[1].timestamp,
})
- expect(store.prefsStorage._journal[2]).to.eql({
- path: 'objectCollections.testing',
- operation: 'removeFromCollection',
- args: [{ _key: 'a' }],
- // should have A timestamp, we don't really care what it is
- timestamp: store.prefsStorage._journal[2].timestamp,
- })
})
it('should remove duplicate entries from journal', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
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.addCollectionPreference({
- path: 'objectCollections.testing',
- value: { _key: 'a', foo: 1 },
- })
- store.addCollectionPreference({
- path: 'objectCollections.testing',
- value: { _key: 'a', foo: 1 },
- })
store.updateCache({ username: 'test' })
expect(store.prefsStorage.simple.testing).to.eql(1)
expect(store.prefsStorage.collections.testing).to.eql([2])
- expect(store.prefsStorage.objectCollections.testing).to.eql({
- data: { a: { _key: 'a', foo: 1 } },
- index: ['a'],
- })
- expect(store.prefsStorage._journal.length).to.eql(4)
+ expect(store.prefsStorage._journal.length).to.eql(2)
})
it('should remove depth = 3 set/unset entries from journal', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.setPreference({ path: 'simple.object.foo', value: 1 })
store.unsetPreference({ path: 'simple.object.foo' })
store.updateCache(store, { username: 'test' })
@@ -204,7 +169,7 @@ describe('The SyncConfig module', () => {
})
it('should not allow unsetting depth <= 2', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.setPreference({ path: 'simple.object.foo', value: 1 })
expect(() => store.unsetPreference({ path: 'simple' })).to.throw()
expect(() =>
@@ -213,7 +178,7 @@ describe('The SyncConfig module', () => {
})
it('should not allow (un)setting depth > 3', () => {
- const store = useSyncConfigStore()
+ const store = useServerSideStorageStore()
store.setPreference({ path: 'simple.object', value: {} })
expect(() =>
store.setPreference({ path: 'simple.object.lv3', value: 1 }),
diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js
index 1315724da..3d1027ad4 100644
--- a/test/unit/specs/modules/statuses.spec.js
+++ b/test/unit/specs/modules/statuses.spec.js
@@ -1,12 +1,10 @@
-import { createTestingPinia } from '@pinia/testing'
-
import {
defaultState,
mutations,
prepareStatus,
} from '../../../../src/modules/statuses.js'
-
-createTestingPinia()
+import { createTestingPinia } from '@pinia/testing'
+ createTestingPinia()
const makeMockStatus = ({ id, text, type = 'status' }) => {
return {
diff --git a/test/unit/specs/services/notification_utils/notification_utils.spec.js b/test/unit/specs/services/notification_utils/notification_utils.spec.js
index 2bfd3c4a1..baafd8961 100644
--- a/test/unit/specs/services/notification_utils/notification_utils.spec.js
+++ b/test/unit/specs/services/notification_utils/notification_utils.spec.js
@@ -1,21 +1,6 @@
-import { createTestingPinia } from '@pinia/testing'
-
-import { useSyncConfigStore } from 'src/stores/sync_config.js'
-
import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'
describe('NotificationUtils', () => {
- beforeEach(() => {
- const store = useSyncConfigStore(createTestingPinia())
- store.mergedConfig = {
- notificationVisibility: {
- likes: true,
- repeats: true,
- mentions: false,
- },
- }
- })
-
describe('filteredNotificationsFromStore', () => {
it('should return sorted notifications with configured types', () => {
const store = {
@@ -41,7 +26,13 @@ describe('NotificationUtils', () => {
},
},
getters: {
- mergedConfig: {},
+ mergedConfig: {
+ notificationVisibility: {
+ likes: true,
+ repeats: true,
+ mentions: false,
+ },
+ },
},
}
const expected = [
diff --git a/test/unit/specs/stores/oauth.spec.js b/test/unit/specs/stores/oauth.spec.js
index 4664bba02..977b15432 100644
--- a/test/unit/specs/stores/oauth.spec.js
+++ b/test/unit/specs/stores/oauth.spec.js
@@ -1,6 +1,6 @@
-import { createTestingPinia } from '@pinia/testing'
import { HttpResponse, http } from 'msw'
-import { createPinia, setActivePinia } from 'pinia'
+import { setActivePinia, createPinia } from 'pinia'
+import { createTestingPinia } from '@pinia/testing'
import {
authApis,
@@ -8,8 +8,8 @@ import {
testServer,
} from '/test/fixtures/mock_api.js'
-import { useInstanceStore } from 'src/stores/instance.js'
import { useOAuthStore } from 'src/stores/oauth.js'
+import { useInstanceStore } from 'src/stores/instance.js'
const test = injectMswToTest(authApis)
@@ -61,6 +61,7 @@ describe('oauth store', () => {
}),
)
+
const store = useOAuthStore()
store.clientId = 'another-id'
store.clientSecret = 'another-secret'
@@ -182,9 +183,7 @@ describe('oauth store', () => {
await expect(store.ensureAppToken()).rejects.toThrowError('Throttled')
})
- test('it should throw if we cannot obtain app token', async ({
- worker,
- }) => {
+ test('it should throw if we cannot obtain app token', async ({ worker }) => {
worker.use(
http.post(`${testServer}/oauth/token`, () => {
return HttpResponse.text('Throttled', { status: 429 })