diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index b6ebc4364..f3f5b76da 100644 --- a/src/components/notification/notification.js +++ b/src/components/notification/notification.js @@ -18,7 +18,6 @@ import UserPopover from '../user_popover/user_popover.vue' import { useInstanceStore } from 'src/stores/instance.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' -import { useUserHighlightStore } from 'src/stores/user_highlight.js' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' @@ -185,7 +184,7 @@ const Notification = { userStyle() { const highlight = useSyncConfigStore().mergedConfig.highlight const user = this.notification.from_profile - return highlightStyle(useUserHighlightStore().get(user)) + return highlightStyle(highlight[user.screen_name]) }, expandable() { return new Set(['like', 'pleroma:emoji_reaction', 'repeat', 'poll']).has( diff --git a/src/components/status/status.js b/src/components/status/status.js index 46f1cb623..634e74f5e 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -23,7 +23,6 @@ import UserPopover from '../user_popover/user_popover.vue' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' -import { useUserHighlightStore } from 'src/stores/user_highlight.js' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' @@ -200,14 +199,16 @@ const Status = { }, repeaterStyle() { const user = this.statusoid.user - return highlightStyle(useUserHighlightStore().get(user.screen_name)) + const highlight = this.mergedConfig.highlight + return highlightStyle(highlight[user.screen_name]) }, userStyle() { if (this.noHeading) return const user = this.retweet ? this.statusoid.retweeted_status.user : this.statusoid.user - return highlightStyle(useUserHighlightStore().get(user.screen_name)) + const highlight = this.mergedConfig.highlight + return highlightStyle(highlight[user.screen_name]) }, userProfileLink() { return this.generateUserProfileLink( diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 491238937..15f2d8e86 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -29,7 +29,6 @@ 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 { useUserHighlightStore } from 'src/stores/user_highlight.js' import { propsToNative } from 'src/services/attributes_helper/attributes_helper.service.js' import localeService from 'src/services/locale/locale.service.js' @@ -227,28 +226,39 @@ export default { })) }, userHighlightType: { - get () { - return useUserHighlightStore().get(this.user.screen_name).type + get() { + const data = + useSyncConfigStore().mergedConfig.highlight[this.user.screen_name] + return (data && data.type) || 'disabled' }, - set (type) { + set(type) { + const data = + useSyncConfigStore().mergedConfig.highlight[this.user.screen_name] if (type !== 'disabled') { - useUserHighlightStore().setAndSave({ + this.$store.dispatch('setHighlight', { user: this.user.screen_name, - value: { type } + color: (data && data.color) || '#FFFFFF', + type, }) } else { - useUserHighlightStore().unsetAndSave({ user: this.user.screen_name }) + this.$store.dispatch('setHighlight', { + user: this.user.screen_name, + color: undefined, + }) } }, + ...mapState(useSyncConfigStore, ['mergedConfig']), }, userHighlightColor: { get() { - return useUserHighlightStore().get(this.user.screen_name).color + const data = + useSyncConfigStore().mergedConfig.highlight[this.user.screen_name] + return data && data.color }, set(color) { - useUserHighlightStore().setAndSave({ + this.$store.dispatch('setHighlight', { user: this.user.screen_name, - value: { color } + color, }) }, }, diff --git a/src/modules/users.js b/src/modules/users.js index ffc40ff25..d3e6eae7c 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -27,7 +27,6 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j import { useInterfaceStore } from 'src/stores/interface.js' import { useOAuthStore } from 'src/stores/oauth.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' -import { useUserHighlightStore } from 'src/stores/user_highlight.js' import { declarations } from 'src/modules/config_declaration' @@ -702,8 +701,7 @@ const users = { user.domainMutes = [] commit('setCurrentUser', user) - useSyncConfigStore().initSyncConfig(user) - useUserHighlightStore().initHighlight(user) + useSyncConfigStore().setSyncConfig(user) commit('addNewUsers', [user]) useEmojiStore().fetchEmoji() diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 0135d1651..62d7fa855 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -117,7 +117,6 @@ export const parseUser = (data) => { if (data.pleroma) { if (data.pleroma.settings_store) { output.storage = data.pleroma.settings_store['pleroma-fe'] - output.user_highlight = data.pleroma.settings_store['user_highlight'] } const relationship = data.pleroma.relationship diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 057fb86ea..b915018d3 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -605,8 +605,7 @@ export const useSyncConfigStore = defineStore('sync_config', { this.raw.prefsStorage._journal = [] this.pushSyncConfig() }, - initSyncConfig(userData) { - console.log(userData) + setSyncConfig(userData) { const live = userData.storage this.raw = live let cache = this.cache @@ -683,7 +682,7 @@ export const useSyncConfigStore = defineStore('sync_config', { window.vuex.state.api.backendInteractor .updateProfileJSON({ params }) .then((user) => { - this.initSyncConfig(user) + this.setSyncConfig(user) this.dirty = false }) }, diff --git a/test/unit/specs/stores/sync_config.spec.js b/test/unit/specs/stores/sync_config.spec.js index 5ae4ab9cc..561f6dcbb 100644 --- a/test/unit/specs/stores/sync_config.spec.js +++ b/test/unit/specs/stores/sync_config.spec.js @@ -22,7 +22,7 @@ describe('The SyncConfig module', () => { }) describe('mutations', () => { - describe('initSyncConfig', () => { + describe('setSyncConfig', () => { const user = { created_at: new Date('1999-02-09'), storage: {}, @@ -30,7 +30,7 @@ describe('The SyncConfig module', () => { it('should initialize storage if none present', () => { const store = useSyncConfigStore() - store.initSyncConfig({ ...user }) + store.setSyncConfig({ ...user }) expect(store.cache._version).to.eql(VERSION) expect(store.cache._timestamp).to.be.a('number') expect(store.cache.flagStorage).to.eql(defaultState.flagStorage) @@ -39,7 +39,7 @@ describe('The SyncConfig module', () => { it('should initialize storage with proper flags for new users if none present', () => { const store = useSyncConfigStore() - store.initSyncConfig({ ...user, created_at: new Date() }) + store.setSyncConfig({ ...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) @@ -54,7 +54,7 @@ describe('The SyncConfig module', () => { ...cloneDeep(defaultState), } - store.initSyncConfig({ + store.setSyncConfig({ ...user, storage: { _timestamp: 123, @@ -79,7 +79,7 @@ describe('The SyncConfig module', () => { const store = useSyncConfigStore() store.cache = null - store.initSyncConfig({ + store.setSyncConfig({ ...user, storage: { _timestamp: 123, @@ -97,7 +97,7 @@ describe('The SyncConfig module', () => { it('should use remote version if local missing', () => { const store = useSyncConfigStore() - store.initSyncConfig(store, user) + store.setSyncConfig(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)