fix tests

This commit is contained in:
Henry Jameson 2026-01-23 17:24:02 +02:00
commit 3cdcb87831
11 changed files with 165 additions and 82 deletions

View file

@ -39,7 +39,7 @@ export default (store) => {
if (store.state.users.currentUser) {
next()
} else {
next(store.state.instance.redirectRootNoLogin || '/main/all')
next(useInstanceStore().redirectRootNoLogin || '/main/all')
}
}

View file

@ -1,3 +1,4 @@
import { mapState as mapPiniaState } from 'pinia'
import { mapState } from 'vuex'
import UserListMenu from 'src/components/user_list_menu/user_list_menu.vue'
@ -6,6 +7,7 @@ import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import Popover from '../popover/popover.vue'
import ProgressButton from '../progress_button/progress_button.vue'
import { useInstanceStore } from 'src/stores/instance'
import { useReportsStore } from 'src/stores/reports'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
@ -94,8 +96,10 @@ const AccountActions = {
shouldConfirmRemoveUserFromFollowers() {
return useSyncConfigStore().mergedConfig.modalOnRemoveUserFromFollowers
},
...mapPiniaState(useInstanceStore, (store) => ({
blockExpirationSupported: (store) => store.featureSet.blockExpiration,
})),
...mapState({
blockExpirationSupported: (state) => state.instance.blockExpiration,
pleromaChatMessagesAvailable: (state) =>
state.instance.pleromaChatMessagesAvailable,
}),

View file

@ -214,6 +214,15 @@ export default {
)
return Math.round(this.user.statuses_count / days)
},
userHighlight() {
console.log(
'UH',
this.userHighlightData,
this.userHighlightIndex,
this.test,
)
return this.userHighlightData[this.user.screen_name.replace(/\./g, '_')]
},
emoji() {
return useEmojiStore().customEmoji.map((e) => ({
shortcode: e.displayText,
@ -223,35 +232,43 @@ export default {
},
userHighlightType: {
get() {
const data = this.highlight[this.user.screen_name]
return (data && data.type) || 'disabled'
return this.userHighlight?.type || 'disabled'
},
set(type) {
const data = this.highlight[this.user.screen_name]
if (type !== 'disabled') {
this.$store.dispatch('setHighlight', {
user: this.user.screen_name,
color: (data && data.color) || '#FFFFFF',
type,
useSyncConfigStore().addCollectionPreference({
path: 'objectCollections.userUserHighlight',
value: {
_key: this.user.screen_name.replace(/\./g, '_'),
color: this.userHighlight?.color || '#FFFFFF',
type,
},
})
useSyncConfigStore().pushSyncConfig()
} else {
this.$store.dispatch('setHighlight', {
user: this.user.screen_name,
color: undefined,
useSyncConfigStore().removeCollectionPreference({
path: 'objectCollections.userUserHighlight',
value: { _key: this.user.screen_name.replace(/\./g, '_') },
})
useSyncConfigStore().pushSyncConfig()
}
},
},
userHighlightColor: {
get() {
const data = this.highlight[this.user.screen_name]
return data && data.color
return this.userHighlight?.color
},
set(color) {
this.$store.dispatch('setHighlight', {
user: this.user.screen_name,
color,
console.log(this.userHighlight)
useSyncConfigStore().addCollectionPreference({
path: 'objectCollections.userUserHighlight',
value: {
_key: this.user.screen_name.replace(/\./g, '_'),
color,
type: this.userHighlight?.type || 'solid',
},
})
useSyncConfigStore().pushSyncConfig()
},
},
visibleRole() {
@ -382,6 +399,11 @@ export default {
})
},
...mapState(useSyncConfigStore, {
test: (store) => store.prefsStorage.objectCollections.userHighlight,
userHighlightData: (store) =>
store.prefsStorage.objectCollections.userHighlight.data,
userHighlightIndex: (store) =>
store.prefsStorage.objectCollections.userHighlight.index,
hideUserStats: (store) => store.mergedConfig.hideUserStats,
userCardLeftJustify: (store) => store.mergedConfig.userCardLeftJustify,
userCardHidePersonalMarks: (store) =>

View file

@ -237,6 +237,7 @@ const _mergeJournal = (...journals) => {
return false
}
if (a.operation === 'addToCollection') {
// TODO check how objectCollections behaves here
return a.args[0] === b.args[0]
}
return false
@ -500,6 +501,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
collection.add(_key)
set(this.prefsStorage, path + '.index', [...collection])
set(this.prefsStorage, path + '.data.' + _key, value)
console.log(get(path, this.prefsStorage, path))
}
this.prefsStorage._journal = [
...this.prefsStorage._journal,
@ -518,19 +520,28 @@ export const useSyncConfigStore = defineStore('sync_config', {
`tried to edit internal (starts with _) field '${path}', ignoring.`,
)
}
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
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)
const data = get(this.prefsStorage, path + '.data')
delete data[_key]
}
},
reorderCollectionPreference({ path, value, movement }) {
if (path.startsWith('_')) {