This commit is contained in:
Henry Jameson 2026-06-01 20:05:25 +03:00
commit caa49744b2
5 changed files with 42 additions and 39 deletions

View file

@ -11,8 +11,8 @@ import ModifiedIndicator from '../helpers/modified_indicator.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js' import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue' import StringSetting from '../helpers/string_setting.vue'
import { useInstanceStore } from 'src/stores/instance.js'
import { useEmojiStore } from 'src/stores/emoji.js' import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInterfaceStore } from 'src/stores/interface.js' import { useInterfaceStore } from 'src/stores/interface.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
@ -176,21 +176,24 @@ const EmojiTab = {
}, },
refreshPackList() { refreshPackList() {
useEmojiStore().getAdminPacks( useEmojiStore()
this.remotePackInstance, .getAdminPacks(
this.$store.state.api.backendInteractor.listEmojiPacks, this.remotePackInstance,
).then((allPacks) => { this.$store.state.api.backendInteractor.listEmojiPacks,
this.knownLocalPacks = allPacks )
for (const name of Object.keys(this.knownLocalPacks)) { .then((allPacks) => {
this.sortPackFiles(name) this.knownLocalPacks = allPacks
} for (const name of Object.keys(this.knownLocalPacks)) {
}) this.sortPackFiles(name)
}
})
}, },
listRemotePacks() { listRemotePacks() {
useEmojiStore().getAdminPacks( useEmojiStore()
this.remotePackInstance, .getAdminPacks(
this.$store.state.api.backendInteractor.listRemoteEmojiPacks, this.remotePackInstance,
) this.$store.state.api.backendInteractor.listRemoteEmojiPacks,
)
.then((allPacks) => { .then((allPacks) => {
let inst = this.remotePackInstance let inst = this.remotePackInstance
if (!inst.startsWith('http')) { if (!inst.startsWith('http')) {

View file

@ -14,8 +14,8 @@ import {
import { import {
faBookmark, faBookmark,
faCheck, faCheck,
faChevronRight,
faChevronDown, faChevronDown,
faChevronRight,
faExternalLinkAlt, faExternalLinkAlt,
faEyeSlash, faEyeSlash,
faHistory, faHistory,

View file

@ -1,11 +1,11 @@
import Popover from 'components/popover/popover.vue' import Popover from 'components/popover/popover.vue'
import SelectComponent from 'components/select/select.vue' import SelectComponent from 'components/select/select.vue'
import StillImage from './still-image.vue'
import { mapState } from 'pinia' import { mapState } from 'pinia'
import { useInterfaceStore } from 'src/stores/interface' import StillImage from './still-image.vue'
import { useEmojiStore } from 'src/stores/emoji' import { useEmojiStore } from 'src/stores/emoji'
import { useInterfaceStore } from 'src/stores/interface'
export default { export default {
components: { StillImage, Popover, SelectComponent }, components: { StillImage, Popover, SelectComponent },
@ -28,7 +28,7 @@ export default {
isUserAdmin() { isUserAdmin() {
return this.$store.state.users.currentUser?.rights.admin return this.$store.state.users.currentUser?.rights.admin
}, },
...mapState(useEmojiStore, ['adminPacksLocal', 'adminPacksLocalLoading']) ...mapState(useEmojiStore, ['adminPacksLocal', 'adminPacksLocalLoading']),
}, },
methods: { methods: {
displayError(msg) { displayError(msg) {
@ -64,9 +64,11 @@ export default {
}, },
fetchEmojiPacksIfAdmin() { fetchEmojiPacksIfAdmin() {
useEmojiStore().getAdminPacksLocal().then(() => { useEmojiStore()
this.$refs.emojiPopover.updateStyles() .getAdminPacksLocal()
}) .then(() => {
this.$refs.emojiPopover.updateStyles()
})
}, },
}, },
} }

View file

@ -3,8 +3,8 @@ import { defineAsyncComponent } from 'vue'
import RichContent from 'src/components/rich_content/rich_content.jsx' import RichContent from 'src/components/rich_content/rich_content.jsx'
import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_indicator.vue' import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_indicator.vue'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceStore } from 'src/stores/instance.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
@ -40,7 +40,7 @@ const UserListPopover = {
useInstanceStore().restrictedNicknames, useInstanceStore().restrictedNicknames,
) )
}, },
} },
} }
export default UserListPopover export default UserListPopover

View file

@ -1,6 +1,6 @@
import { merge } from 'lodash'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { merge } from 'lodash'
import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceStore } from 'src/stores/instance.js'
import { ensureFinalFallback } from 'src/i18n/languages.js' import { ensureFinalFallback } from 'src/i18n/languages.js'
@ -187,7 +187,10 @@ export const useEmojiStore = defineStore('emoji', {
const listFunction = backendInteractor.listEmojiPacks const listFunction = backendInteractor.listEmojiPacks
this.adminPacksLocalLoading = true this.adminPacksLocalLoading = true
this.adminPacksLocal = await this.getAdminPacks(useInstanceStore().server, listFunction) this.adminPacksLocal = await this.getAdminPacks(
useInstanceStore().server,
listFunction,
)
this.adminPacksLocalLoading = false this.adminPacksLocalLoading = false
}, },
@ -197,8 +200,6 @@ export const useEmojiStore = defineStore('emoji', {
if (!currentUser.rights.admin) return if (!currentUser.rights.admin) return
const pageSize = 25 const pageSize = 25
const allPacks = {}
return await listFunction({ return await listFunction({
instance, instance,
@ -222,25 +223,22 @@ export const useEmojiStore = defineStore('emoji', {
}) })
.then((data) => data.json()) .then((data) => data.json())
.then((pageData) => { .then((pageData) => {
if (pageData.error !== undefined) { if (pageData.error !== undefined) {
return Promise.reject(pageData.error) return Promise.reject(pageData.error)
} }
return pageData.packs return pageData.packs
}) }),
) )
} }
return Promise return Promise.all(promises).then((results) => {
.all(promises) return merge({}, ...results)
.then((results) => { })
return merge({}, ...results)
})
}) })
.then((allPacks) => { .then((allPacks) => {
// Sort by key // Sort by key
return Object return Object.keys(allPacks)
.keys(allPacks)
.sort() .sort()
.reduce((acc, key) => { .reduce((acc, key) => {
if (key.length === 0) return acc if (key.length === 0) return acc