diff --git a/src/components/chat_message/chat_message.js b/src/components/chat_message/chat_message.js index 2ab3a60d1..983159bcb 100644 --- a/src/components/chat_message/chat_message.js +++ b/src/components/chat_message/chat_message.js @@ -86,7 +86,7 @@ const ChatMessage = { } }, ...mapGetters(['findUser']), - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), }, data() { return { diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 5d5b933e1..fab1cb38f 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -79,37 +79,12 @@ const conversation = { } }, computed: { - maxDepthToShowByDefault() { - // 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 - return maxDepth >= 1 ? maxDepth : 1 - }, - streamingEnabled() { - return ( - useSyncConfigStore().mergedConfig.useStreamingApi && - this.mastoUserSocketStatus === WSConnectionStatus.JOINED - ) - }, - displayStyle() { - return useSyncConfigStore().mergedConfig.conversationDisplay - }, isTreeView() { return !this.isLinearView }, - treeViewIsSimple() { - return !useSyncConfigStore().mergedConfig.conversationTreeAdvanced - }, isLinearView() { return this.displayStyle === 'linear' }, - shouldFadeAncestors() { - return useSyncConfigStore().mergedConfig.conversationTreeFadeAncestors - }, - otherRepliesButtonPosition() { - return useSyncConfigStore().mergedConfig.conversationOtherRepliesButton - }, showOtherRepliesButtonBelowStatus() { return this.otherRepliesButtonPosition === 'below' }, @@ -394,7 +369,28 @@ const conversation = { maybeHighlight() { return this.isExpanded ? this.highlight : null }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, { + maxDepthToShowByDefault: (store) => { + // 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 = store.mergedConfig.maxDepthInThread - 2 + return maxDepth >= 1 ? maxDepth : 1 + }, + streamingEnabled: (store) => { + return ( + store.mergedConfig.useStreamingApi && + this.mastoUserSocketStatus === WSConnectionStatus.JOINED + ) + }, + displayStyle: (store) => store.mergedConfig.conversationDisplay, + treeViewIsSimple: (store) => !store.mergedConfig.conversationTreeAdvanced, + shouldFadeAncestors: (store) => + store.mergedConfig.conversationTreeFadeAncestors, + otherRepliesButtonPosition: (store) => + store.mergedConfig.conversationOtherRepliesButton, + }), ...mapState({ mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus, }), diff --git a/src/components/settings_modal/tabs/style_tab/style_tab.js b/src/components/settings_modal/tabs/style_tab/style_tab.js index 8365645fc..c507dca0f 100644 --- a/src/components/settings_modal/tabs/style_tab/style_tab.js +++ b/src/components/settings_modal/tabs/style_tab/style_tab.js @@ -24,7 +24,8 @@ import StringSetting from '../../helpers/string_setting.vue' import Preview from '../old_theme_tab/theme_preview.vue' import VirtualDirectivesTab from './virtual_directives_tab.vue' -import { useInterfaceStore, useSyncConfigStore } from 'src/stores/interface' +import { useInterfaceStore } from 'src/stores/interface' +import { useSyncConfigStore } from 'src/stores/sync_config' import { getContrastRatio, diff --git a/src/components/still-image/still-image-emoji-popover.js b/src/components/still-image/still-image-emoji-popover.js new file mode 100644 index 000000000..0d382d357 --- /dev/null +++ b/src/components/still-image/still-image-emoji-popover.js @@ -0,0 +1,127 @@ +import Popover from 'components/popover/popover.vue' +import SelectComponent from 'components/select/select.vue' +import { assign } from 'lodash' + +import StillImage from './still-image.vue' + +import { useInstanceStore } from 'src/stores/instance.js' +import { useInterfaceStore } from 'src/stores/interface' + +export default { + components: { StillImage, Popover, SelectComponent }, + props: { + shortcode: { + type: String, + required: true, + }, + isLocal: { + type: Boolean, + required: true, + }, + }, + data() { + return { + knownLocalPacks: {}, + packName: '', + } + }, + computed: { + isUserAdmin() { + return this.$store.state.users.currentUser.rights.admin + }, + }, + methods: { + displayError(msg) { + useInterfaceStore().pushGlobalNotice({ + messageKey: 'admin_dash.emoji.error', + messageArgs: [msg], + level: 'error', + }) + }, + copyToLocalPack() { + this.$store.state.api.backendInteractor + .addNewEmojiFile({ + packName: this.packName, + file: this.$attrs.src, + shortcode: this.shortcode, + filename: '', + }) + .then((resp) => resp.json()) + .then((resp) => { + if (resp.error !== undefined) { + this.displayError(resp.error) + return + } + useInterfaceStore().pushGlobalNotice({ + messageKey: 'admin_dash.emoji.copied_successfully', + messageArgs: [this.shortcode, this.packName], + level: 'success', + }) + + this.$refs.emojiPopover.hidePopover() + this.packName = '' + }) + }, + + // Copied from emoji_tab.js + loadPacksPaginated(listFunction) { + const pageSize = 25 + const allPacks = {} + + return listFunction({ + instance: useInstanceStore().server, + page: 1, + pageSize: 0, + }) + .then((data) => data.json()) + .then((data) => { + if (data.error !== undefined) { + return Promise.reject(data.error) + } + + let resultingPromise = Promise.resolve({}) + for (let i = 0; i < Math.ceil(data.count / pageSize); i++) { + resultingPromise = resultingPromise + .then(() => + listFunction({ + instance: useInstanceStore().server, + page: i, + pageSize, + }), + ) + .then((data) => data.json()) + .then((pageData) => { + if (pageData.error !== undefined) { + return Promise.reject(pageData.error) + } + + assign(allPacks, pageData.packs) + }) + } + + return resultingPromise + }) + .then(() => allPacks) + .catch((data) => { + this.displayError(data) + }) + }, + fetchEmojiPacksIfAdmin() { + if (!this.isUserAdmin) return + + this.loadPacksPaginated( + this.$store.state.api.backendInteractor.listEmojiPacks, + ).then((allPacks) => { + // Sort by key + const sorted = Object.keys(allPacks) + .sort() + .reduce((acc, key) => { + if (key.length === 0) return acc + acc[key] = allPacks[key] + return acc + }, {}) + this.knownLocalPacks = sorted + }) + }, + }, +} diff --git a/src/components/still-image/still-image-emoji-popover.vue b/src/components/still-image/still-image-emoji-popover.vue index 4e087c094..2171b8612 100644 --- a/src/components/still-image/still-image-emoji-popover.vue +++ b/src/components/still-image/still-image-emoji-popover.vue @@ -55,135 +55,7 @@ - + +