This commit is contained in:
Henry Jameson 2026-09-02 17:26:08 +03:00
commit c611788e77
19 changed files with 59 additions and 122 deletions

View file

@ -17,8 +17,11 @@ const CHANGE_EMAIL_URL = '/api/pleroma/change_email'
const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const MOVE_ACCOUNT_URL = '/api/pleroma/move_account'
const ALIASES_URL = '/api/pleroma/aliases'
const NOTIFICATION_SETTINGS_URL = ({ blockFromStrangers, hideNotificationContents }) =>
`/api/pleroma/notification_settings${paramsString({ blockFromStrangers, hideNotificationContents })}`
const NOTIFICATION_SETTINGS_URL = ({
blockFromStrangers,
hideNotificationContents,
}) =>
`/api/pleroma/notification_settings${paramsString({ blockFromStrangers, hideNotificationContents })}`
export const NOTIFICATION_READ_URL = '/api/v1/pleroma/notifications/read'
const MFA_SETTINGS_URL = '/api/pleroma/accounts/mfa'

View file

@ -5,9 +5,9 @@ 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 { useDraftsStore } from 'src/stores/drafts.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useStatusesStore } from 'src/stores/statuses.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faPollH } from '@fortawesome/free-solid-svg-icons'
@ -92,9 +92,11 @@ const Draft = {
this.showingConfirmDialog = true
},
doAbandon() {
useDraftsStore().abandonDraft(this.draft.id).then(() => {
this.hideConfirmDialog()
})
useDraftsStore()
.abandonDraft(this.draft.id)
.then(() => {
this.hideConfirmDialog()
})
},
hideConfirmDialog() {
this.showingConfirmDialog = false

View file

@ -1,9 +1,10 @@
import { defineAsyncComponent } from 'vue'
import { useDraftsStore } from 'src/stores/drafts.js'
import Draft from 'src/components/draft/draft.vue'
import List from 'src/components/list/list.vue'
import { useDraftsStore } from 'src/stores/drafts.js'
const Drafts = {
components: {
Draft,
@ -27,7 +28,8 @@ const Drafts = {
this.showingConfirmDialog = true
},
doAbandonAll() {
useDraftsStore().abandonAllDrafts()
useDraftsStore()
.abandonAllDrafts()
.then(() => this.hideConfirmDialog())
},
hideConfirmDialog() {

View file

@ -4,11 +4,11 @@ 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 { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useChatsStore } from 'src/stores/chats.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'

View file

@ -24,6 +24,7 @@ import { findOffset } from '../../services/offset_finder/offset_finder.service.j
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import statusPoster from '../../services/status_poster/status_poster.service.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
@ -32,7 +33,6 @@ import { useMediaViewerStore } from 'src/stores/media_viewer.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { pollFormToMasto } from 'src/services/poll/poll.service.js'

View file

@ -8,8 +8,8 @@ import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { useLocalConfigStore } from 'src/stores/local_config.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
export default {
components: {
@ -413,7 +413,8 @@ export default {
hardReset() {
switch (this.realSource) {
case 'admin':
return useAdminSettingsStore().resetAdminSetting({ path: this.path })
return useAdminSettingsStore()
.resetAdminSetting({ path: this.path })
.then(() => {
this.draft = this.state
})

View file

@ -16,8 +16,8 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
import { useInterfaceStore } from 'src/stores/interface.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useOAuthStore } from 'src/stores/oauth.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js'
import { updateProfile } from 'src/api/user.js'

View file

@ -7,6 +7,7 @@ import { unseenNotifications } from '../../services/notification_utils/notificat
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
@ -14,7 +15,6 @@ import { useInterfaceStore } from 'src/stores/interface'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useShoutStore } from 'src/stores/shout'
import { useUsersStore } from 'src/stores/users.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {

View file

@ -1,11 +1,7 @@
import { cloneDeep, each, get, merge, set } from 'lodash'
import { cloneDeep, get, set } from 'lodash'
import { storage } from './storage.js'
import { useInterfaceStore } from 'src/stores/interface'
let loaded = false
const defaultReducer = (state, paths) =>
paths.length === 0
? state
@ -14,15 +10,6 @@ const defaultReducer = (state, paths) =>
return substate
}, {})
const saveImmedeatelyActions = [
'markNotificationsAsSeen',
'setHighlight',
'setOption',
'setClientData',
'setToken',
'clearToken',
]
const defaultStorage = (() => {
return storage
})()

View file

@ -33,10 +33,6 @@ const i18n = createI18n({
messages.setLanguage(i18n.global, currentLocale)
const persistedStateOptions = {
paths: ['oauth', 'config'],
}
;(async () => {
const isFox = Math.floor(Math.random() * 2) > 0 ? '_fox' : ''

View file

@ -1,4 +1,5 @@
import { defineStore } from 'pinia'
import { storage } from 'src/lib/storage.js'
const storageKey = 'pleroma-fe-drafts'
@ -18,13 +19,13 @@ const storageKey = 'pleroma-fe-drafts'
const getStorageData = async () => await storage.getItem(storageKey)
const saveDraftToStorage = async (draft) => {
const currentData = await getStorageData() ?? {}
const currentData = (await getStorageData()) ?? {}
currentData[draft.id] = JSON.parse(JSON.stringify(draft))
await storage.setItem(storageKey, currentData)
}
const deleteDraftFromStorage = async (ids) => {
const currentData = await getStorageData() ?? {}
const currentData = (await getStorageData()) ?? {}
ids.forEach((id) => {
delete currentData[id]
})
@ -33,7 +34,7 @@ const deleteDraftFromStorage = async (ids) => {
export const useDraftsStore = defineStore('drafts', {
state: () => ({
drafts: new Map()
drafts: new Map(),
}),
getters: {
draftsByTypeAndRefId(state) {
@ -71,5 +72,5 @@ export const useDraftsStore = defineStore('drafts', {
ids.forEach((id) => this.abandonDraft(id))
await deleteDraftFromStorage(ids)
},
}
},
})

View file

@ -97,7 +97,9 @@ export const settingsMap = {
}
export const defaultState = () => ({
config: Object.fromEntries(Object.keys(settingsMap).map((key) => [key, null]))
config: Object.fromEntries(
Object.keys(settingsMap).map((key) => [key, null]),
),
})
export const useProfileConfigStore = defineStore('profileConfig', {

View file

@ -5,6 +5,7 @@ import { defineStore } from 'pinia'
import { useAnnouncementsStore } from 'src/stores/announcements.js'
import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders.js'
import { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useEmojiStore } from 'src/stores/emoji.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useInstanceStore } from 'src/stores/instance.js'
@ -14,14 +15,13 @@ import { useListsStore } from 'src/stores/lists.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useNotificationsStore } from 'src/stores/notifications.js'
import { useOAuthStore } from 'src/stores/oauth.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useShoutStore } from 'src/stores/shout.js'
import { useStatusesStore } from 'src/stores/statuses.js'
import { useStreamingStore } from 'src/stores/streaming.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useTimelinesStore } from 'src/stores/timelines.js'
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { revokeToken } from 'src/api/oauth.js'
import {

View file

@ -5,26 +5,15 @@ import VueVirtualScroller from 'vue-virtual-scroller'
import RichContent from 'src/components/rich_content/rich_content.jsx'
import Status from 'src/components/status/status.vue'
import StillImage from 'src/components/still-image/still-image.vue'
import makeMockStore from './mock_store'
import routes from 'src/boot/routes'
export const $t = (msg) => msg
const $i18n = { t: (msg) => msg }
const applyAfterStore = (store, afterStore) => {
afterStore(store)
return store
}
const getDefaultOpts = ({
afterStore = () => {
/* no-op */
},
} = {}) => ({
const getDefaultOpts = () => ({
global: {
plugins: [
applyAfterStore(makeMockStore(), afterStore),
VueVirtualScroller,
createRouter({
history: createMemoryHistory(),
@ -87,9 +76,8 @@ const customBehaviors = () => {
config.plugins.VueWrapper.install(customBehaviors)
export const mountOpts = (allOpts = {}) => {
const { afterStore, ...opts } = allOpts
const defaultOpts = getDefaultOpts({ afterStore })
export const mountOpts = (opts = {}) => {
const defaultOpts = getDefaultOpts()
const mergedOpts = {
...opts,
global: {

View file

@ -1,10 +1,10 @@
import { createTestingPinia } from '@pinia/testing'
import { flushPromises, mount } from '@vue/test-utils'
import { setActivePinia } from 'pinia'
import { $t, mountOpts, waitForEvent } from 'test/fixtures/setup_test.js'
import { nextTick } from 'vue'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useUsersStore } from 'src/stores/users.js'

View file

@ -1,10 +1,10 @@
import { createTestingPinia } from '@pinia/testing'
import { mount } from '@vue/test-utils'
import { setActivePinia } from 'pinia'
import { mountOpts } from 'test/fixtures/setup_test.js'
import { vi } from 'vitest'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import { mountOpts } from '../../../fixtures/setup_test'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'

View file

@ -1,9 +1,9 @@
import { createTestingPinia } from '@pinia/testing'
import { mount, shallowMount } from '@vue/test-utils'
import { setActivePinia } from 'pinia'
import { mountOpts } from 'test/fixtures/setup_test.js'
import RichContent from 'src/components/rich_content/rich_content.jsx'
import { mountOpts } from '../../../fixtures/setup_test'
const attentions = []

View file

@ -37,10 +37,7 @@ describe('The SyncConfig store', () => {
it('should initialize storage if none present', async () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({ ...user })
expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number')
@ -50,10 +47,7 @@ describe('The SyncConfig store', () => {
it('should initialize storage with proper flags for new users if none present', async () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({ ...user, created_at: new Date() })
expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number')
@ -63,10 +57,7 @@ describe('The SyncConfig store', () => {
it('should merge flags even if remote timestamp is older', async () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.cache = {
_timestamp: Date.now(),
_version: VERSION,
@ -96,10 +87,7 @@ describe('The SyncConfig store', () => {
it('should trim journal to 500 entries', async () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.cache = {
_timestamp: Date.now(),
_version: VERSION,
@ -138,10 +126,7 @@ describe('The SyncConfig store', () => {
it('should reset local timestamp to remote if contents are the same', async () => {
const store = useSyncConfigStore()
store.cache = null
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({
...user,
@ -161,10 +146,7 @@ describe('The SyncConfig store', () => {
it('should use remote version if local missing', async () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig(store, user)
expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number')
@ -208,9 +190,7 @@ describe('The SyncConfig store', () => {
})
vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore()
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({
...user,
@ -240,9 +220,7 @@ describe('The SyncConfig store', () => {
})
vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore()
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({
...user,
@ -282,9 +260,7 @@ describe('The SyncConfig store', () => {
vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore()
const setPreference = vi.spyOn(store, 'setPreference')
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({
...user,
@ -318,9 +294,7 @@ describe('The SyncConfig store', () => {
})
vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore()
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({
...user,
@ -357,9 +331,7 @@ describe('The SyncConfig store', () => {
const localStore = useLocalConfigStore()
localStore.set({ path: 'fontInterface', value: 'Current interface' })
const store = useSyncConfigStore()
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
await store.initSyncConfig({ ...user })
@ -372,10 +344,7 @@ describe('The SyncConfig store', () => {
describe('setPreference', () => {
it('should set preference and update journal log accordingly', () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.setPreference({ path: 'simple.palette', value: '1' })
expect(store.prefsStorage.simple.palette).to.eql('1')
expect(store.prefsStorage._journal).to.have.length(1)
@ -390,10 +359,7 @@ describe('The SyncConfig store', () => {
it('should keep journal to a minimum', () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.setPreference({ path: 'simple.palette', value: 1 })
store.setPreference({ path: 'simple.palette', value: 2 })
store.addCollectionPreference({ path: 'collections.palette', value: 2 })
@ -423,10 +389,7 @@ describe('The SyncConfig store', () => {
it('should remove duplicate entries from journal', () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.setPreference({ path: 'simple.palette', value: 1 })
store.setPreference({ path: 'simple.palette', value: 1 })
store.addCollectionPreference({ path: 'collections.palette', value: 2 })
@ -440,10 +403,7 @@ describe('The SyncConfig store', () => {
// TODO We need a proper test for object-based stores
it.skip('should remove depth = 3 set/unset entries from journal', () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.setPreference({ path: 'simple.fontInput', value: 'test' })
store.unsetPreference({ path: 'simple.fontInput' })
store.updateCache(store, { username: 'test' })
@ -455,10 +415,7 @@ describe('The SyncConfig store', () => {
it('should not allow unsetting depth <= 2', () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.setPreference({ path: 'simple.object.foo', value: 1 })
expect(() => store.unsetPreference({ path: 'simple' })).to.throw()
expect(() =>
@ -468,10 +425,7 @@ describe('The SyncConfig store', () => {
it('should not allow (un)setting depth > 3', () => {
const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data
store.pushSyncConfig = () => {
/* no-op */
}
store.pushSyncConfig = vi.fn()
store.setPreference({ path: 'simple.object', value: {} })
expect(() =>
store.setPreference({ path: 'simple.object.lv3', value: 1 }),

View file

@ -120,6 +120,7 @@ export default defineConfig(async ({ mode, command }) => {
const swDest = 'sw-pleroma.js'
const alias = {
src: '/src',
test: '/test',
components: '/src/components',
...(mode === 'test' ? { vue: 'vue/dist/vue.esm-bundler.js' } : {}),
}