cleaned and fixed errors detected by biome
This commit is contained in:
parent
ae17911560
commit
6aadf5f1c6
16 changed files with 37 additions and 347 deletions
|
|
@ -17,6 +17,7 @@ import {
|
||||||
} from './chat_layout_utils.js'
|
} from './chat_layout_utils.js'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faChevronDown, faChevronLeft } from '@fortawesome/free-solid-svg-icons'
|
import { faChevronDown, faChevronLeft } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -109,11 +110,11 @@ const Chat = {
|
||||||
'currentChat',
|
'currentChat',
|
||||||
'currentChatMessageService',
|
'currentChatMessageService',
|
||||||
'findOpenedChatByRecipientId',
|
'findOpenedChatByRecipientId',
|
||||||
'mergedConfig',
|
|
||||||
]),
|
]),
|
||||||
...mapPiniaState(useInterfaceStore, {
|
...mapPiniaState(useInterfaceStore, {
|
||||||
mobileLayout: (store) => store.layoutType === 'mobile',
|
mobileLayout: (store) => store.layoutType === 'mobile',
|
||||||
}),
|
}),
|
||||||
|
...mapPiniaState(useSyncConfigStore, ['mergedConfig']),
|
||||||
...mapState({
|
...mapState({
|
||||||
backendInteractor: (state) => state.api.backendInteractor,
|
backendInteractor: (state) => state.api.backendInteractor,
|
||||||
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ import Popover from '../popover/popover.vue'
|
||||||
import StatusContent from '../status_content/status_content.vue'
|
import StatusContent from '../status_content/status_content.vue'
|
||||||
import UserAvatar from '../user_avatar/user_avatar.vue'
|
import UserAvatar from '../user_avatar/user_avatar.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faEllipsisH, faTimes } from '@fortawesome/free-solid-svg-icons'
|
import { faEllipsisH, faTimes } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -84,7 +85,8 @@ const ChatMessage = {
|
||||||
return { left: 50 }
|
return { left: 50 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig', 'findUser']),
|
...mapGetters(['findUser']),
|
||||||
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { mapGetters } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import Select from 'src/components/select/select.vue'
|
import Select from 'src/components/select/select.vue'
|
||||||
import ConfirmModal from './confirm_modal.vue'
|
import ConfirmModal from './confirm_modal.vue'
|
||||||
|
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['type', 'user', 'status'],
|
props: ['type', 'user', 'status'],
|
||||||
emits: ['hide', 'show', 'muted'],
|
emits: ['hide', 'show', 'muted'],
|
||||||
|
|
@ -43,7 +45,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig']),
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
optionallyPrompt() {
|
optionallyPrompt() {
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ const conversation = {
|
||||||
maybeHighlight() {
|
maybeHighlight() {
|
||||||
return this.isExpanded ? this.highlight : null
|
return this.isExpanded ? this.highlight : null
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig']),
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
...mapState({
|
...mapState({
|
||||||
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { mapGetters } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
const LinkPreview = {
|
const LinkPreview = {
|
||||||
name: 'LinkPreview',
|
name: 'LinkPreview',
|
||||||
|
|
@ -24,7 +26,7 @@ const LinkPreview = {
|
||||||
hideNsfwConfig() {
|
hideNsfwConfig() {
|
||||||
return this.mergedConfig.hideNsfw
|
return this.mergedConfig.hideNsfw
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig']),
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.useImage) {
|
if (this.useImage) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { mapState as mapPiniaState } from 'pinia'
|
import { mapState as mapPiniaState } from 'pinia'
|
||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import { mapGetters, mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
highlightClass,
|
highlightClass,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import { mapGetters } from 'vuex'
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import MentionLink from 'src/components/mention_link/mention_link.vue'
|
import MentionLink from 'src/components/mention_link/mention_link.vue'
|
||||||
|
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
export const MENTIONS_LIMIT = 5
|
export const MENTIONS_LIMIT = 5
|
||||||
|
|
||||||
const MentionsLine = {
|
const MentionsLine = {
|
||||||
|
|
@ -26,7 +28,7 @@ const MentionsLine = {
|
||||||
manyMentions() {
|
manyMentions() {
|
||||||
return this.extraMentions.length > 0
|
return this.extraMentions.length > 0
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig']),
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleShowMore() {
|
toggleShowMore() {
|
||||||
|
|
|
||||||
|
|
@ -206,13 +206,13 @@ const PostStatusForm = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusType === 'edit') {
|
if (statusType === 'edit') {
|
||||||
const statusContentType = this.statusContentType || contentType
|
const statusContentType = this.statusContentType || this.contentType
|
||||||
statusParams = {
|
statusParams = {
|
||||||
type: statusType,
|
type: statusType,
|
||||||
refId,
|
refId,
|
||||||
spoilerText: this.subject || '',
|
spoilerText: this.subject || '',
|
||||||
status: this.statusText || '',
|
status: this.statusText || '',
|
||||||
nsfw: this.statusIsSensitive || !!sensitiveByDefault,
|
nsfw: this.statusIsSensitive || !!this.sensitiveByDefault,
|
||||||
files: this.statusFiles || [],
|
files: this.statusFiles || [],
|
||||||
poll: this.statusPoll || {},
|
poll: this.statusPoll || {},
|
||||||
hasPoll: false,
|
hasPoll: false,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { mapState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
import Popover from '../popover/popover.vue'
|
import Popover from '../popover/popover.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons'
|
import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
@ -31,7 +31,7 @@ const QuickFilterSettings = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['mergedConfig']),
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
...mapState(useInterfaceStore, {
|
...mapState(useInterfaceStore, {
|
||||||
mobileLayout: (state) => state.layoutType === 'mobile',
|
mobileLayout: (state) => state.layoutType === 'mobile',
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import Popover from 'src/components/popover/popover.vue'
|
||||||
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
|
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface'
|
import { useInterfaceStore } from 'src/stores/interface'
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -36,7 +37,7 @@ const QuickViewSettings = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['mergedConfig']),
|
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||||
...mapState(useInterfaceStore, {
|
...mapState(useInterfaceStore, {
|
||||||
mobileLayout: (state) => state.layoutType === 'mobile',
|
mobileLayout: (state) => state.layoutType === 'mobile',
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,10 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const revert = () => {
|
const revert = () => {
|
||||||
useSyncConfigStore().setPreference({ path: writePath, value: oldValue })
|
useSyncConfigStore().setPreference({
|
||||||
|
path: writePath,
|
||||||
|
value: oldValue,
|
||||||
|
})
|
||||||
useInterfaceStore().clearTemporaryChanges()
|
useInterfaceStore().clearTemporaryChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -336,16 +336,10 @@ const AppearanceTab = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isThemeActive(key) {
|
isThemeActive(key) {
|
||||||
return (
|
return key === useSyncConfigStore().mergedConfig.theme
|
||||||
key ===
|
|
||||||
(useSyncConfigStore().mergedConfig.theme)
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
isStyleActive(key) {
|
isStyleActive(key) {
|
||||||
return (
|
return key === useSyncConfigStore().mergedConfig.style
|
||||||
key ===
|
|
||||||
(useSyncConfigStore().mergedConfig.style)
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
isPaletteActive(key) {
|
isPaletteActive(key) {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { mapState } from 'pinia'
|
import { mapState } from 'pinia'
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,6 @@ const StatusContent = {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
localCollapseSubjectDefault() {
|
|
||||||
return this.mergedConfig.collapseMessageWithSubject
|
|
||||||
},
|
|
||||||
attachmentSize() {
|
attachmentSize() {
|
||||||
if (this.compact) {
|
if (this.compact) {
|
||||||
return 'small'
|
return 'small'
|
||||||
|
|
@ -121,13 +118,14 @@ const StatusContent = {
|
||||||
}
|
}
|
||||||
return 'normal'
|
return 'normal'
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig']),
|
|
||||||
...mapState({
|
...mapState({
|
||||||
currentUser: (state) => state.users.currentUser,
|
currentUser: (state) => state.users.currentUser,
|
||||||
}),
|
}),
|
||||||
...mapPiniaState(useSyncConfigStore, {
|
...mapPiniaState(useSyncConfigStore, {
|
||||||
maxThumbnails: (store) => store.prefsStorage.simple.maxThumbnails,
|
localCollapseSubjectDefault: (store) =>
|
||||||
hideAttachments: (store) => store.prefsStorage.simple.hideAttachments,
|
store.mergedConfig.collapseMessageWithSubject,
|
||||||
|
maxThumbnails: (store) => store.mergedConfig.maxThumbnails,
|
||||||
|
hideAttachments: (store) => store.mergedConfig.hideAttachments,
|
||||||
hideAttachmentsInConv: (store) =>
|
hideAttachmentsInConv: (store) =>
|
||||||
store.prefsStorage.simple.hideAttachmentsInConv,
|
store.prefsStorage.simple.hideAttachmentsInConv,
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export const piniaStylePlugin = ({ store, options }) => {
|
||||||
if (store.$id === 'sync_config') {
|
if (store.$id === 'sync_config') {
|
||||||
store.$onAction(({ name, args, after }) => {
|
store.$onAction(({ name, args, after }) => {
|
||||||
if (name === 'setPreference') {
|
if (name === 'setPreference') {
|
||||||
const { path, value } = args[0]
|
const { path } = args[0]
|
||||||
if (APPEARANCE_SETTINGS_KEYS.has(path)) {
|
if (APPEARANCE_SETTINGS_KEYS.has(path)) {
|
||||||
after(() => applyStyleConfig(store.mergedConfig))
|
after(() => applyStyleConfig(store.mergedConfig))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,314 +0,0 @@
|
||||||
// See build/emojis_plugin for more details
|
|
||||||
|
|
||||||
import apiService from '../services/api/api.service.js'
|
|
||||||
import { instanceDefaultProperties } from './config.js'
|
|
||||||
import {
|
|
||||||
instanceDefaultConfig,
|
|
||||||
staticOrApiConfigDefault,
|
|
||||||
} from './default_config_state.js'
|
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
|
||||||
|
|
||||||
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
|
||||||
|
|
||||||
import { annotationsLoader } from 'virtual:pleroma-fe/emoji-annotations'
|
|
||||||
|
|
||||||
const SORTED_EMOJI_GROUP_IDS = [
|
|
||||||
'smileys-and-emotion',
|
|
||||||
'people-and-body',
|
|
||||||
'animals-and-nature',
|
|
||||||
'food-and-drink',
|
|
||||||
'travel-and-places',
|
|
||||||
'activities',
|
|
||||||
'objects',
|
|
||||||
'symbols',
|
|
||||||
'flags',
|
|
||||||
]
|
|
||||||
|
|
||||||
const REGIONAL_INDICATORS = (() => {
|
|
||||||
const start = 0x1f1e6
|
|
||||||
const end = 0x1f1ff
|
|
||||||
const A = 'A'.codePointAt(0)
|
|
||||||
const res = new Array(end - start + 1)
|
|
||||||
for (let i = start; i <= end; ++i) {
|
|
||||||
const letter = String.fromCodePoint(A + i - start)
|
|
||||||
res[i - start] = {
|
|
||||||
replacement: String.fromCodePoint(i),
|
|
||||||
imageUrl: false,
|
|
||||||
displayText: 'regional_indicator_' + letter,
|
|
||||||
displayTextI18n: {
|
|
||||||
key: 'emoji.regional_indicator',
|
|
||||||
args: { letter },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})()
|
|
||||||
|
|
||||||
const REMOTE_INTERACTION_URL = '/main/ostatus'
|
|
||||||
|
|
||||||
const defaultState = {
|
|
||||||
// Stuff from apiConfig
|
|
||||||
name: 'Pleroma FE',
|
|
||||||
registrationOpen: true,
|
|
||||||
server: 'http://localhost:4040/',
|
|
||||||
textlimit: 5000,
|
|
||||||
themesIndex: undefined,
|
|
||||||
stylesIndex: undefined,
|
|
||||||
palettesIndex: undefined,
|
|
||||||
themeData: undefined, // used for theme editor v2
|
|
||||||
vapidPublicKey: undefined,
|
|
||||||
|
|
||||||
// Stuff from static/config.json
|
|
||||||
loginMethod: 'password',
|
|
||||||
disableUpdateNotification: false,
|
|
||||||
|
|
||||||
fontsOverride: {},
|
|
||||||
|
|
||||||
// Instance-wide configurations that should not be changed by individual users
|
|
||||||
...staticOrApiConfigDefault,
|
|
||||||
// Instance admins can override default settings for the whole instance
|
|
||||||
...instanceDefaultConfig,
|
|
||||||
|
|
||||||
// Nasty stuff
|
|
||||||
customEmoji: [],
|
|
||||||
customEmojiFetched: false,
|
|
||||||
emoji: {},
|
|
||||||
emojiFetched: false,
|
|
||||||
unicodeEmojiAnnotations: {},
|
|
||||||
pleromaExtensionsAvailable: true,
|
|
||||||
postFormats: [],
|
|
||||||
restrictedNicknames: [],
|
|
||||||
safeDM: true,
|
|
||||||
knownDomains: [],
|
|
||||||
birthdayRequired: false,
|
|
||||||
birthdayMinAge: 0,
|
|
||||||
|
|
||||||
// Feature-set, apparently, not everything here is reported...
|
|
||||||
shoutAvailable: false,
|
|
||||||
pleromaChatMessagesAvailable: false,
|
|
||||||
pleromaCustomEmojiReactionsAvailable: false,
|
|
||||||
pleromaBookmarkFoldersAvailable: false,
|
|
||||||
pleromaPublicFavouritesAvailable: true,
|
|
||||||
statusNotificationTypeAvailable: true,
|
|
||||||
gopherAvailable: false,
|
|
||||||
mediaProxyAvailable: false,
|
|
||||||
suggestionsEnabled: false,
|
|
||||||
suggestionsWeb: '',
|
|
||||||
quotingAvailable: false,
|
|
||||||
groupActorAvailable: false,
|
|
||||||
blockExpiration: false,
|
|
||||||
localBubbleInstances: [], // Akkoma
|
|
||||||
|
|
||||||
// Html stuff
|
|
||||||
instanceSpecificPanelContent: '',
|
|
||||||
tos: '',
|
|
||||||
|
|
||||||
// Version Information
|
|
||||||
backendVersion: '',
|
|
||||||
backendRepository: '',
|
|
||||||
frontendVersion: '',
|
|
||||||
|
|
||||||
pollsAvailable: false,
|
|
||||||
pollLimits: {
|
|
||||||
max_options: 4,
|
|
||||||
max_option_chars: 255,
|
|
||||||
min_expiration: 60,
|
|
||||||
max_expiration: 60 * 60 * 24,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadAnnotations = (lang) => {
|
|
||||||
return annotationsLoader[lang]().then((k) => k.default)
|
|
||||||
}
|
|
||||||
|
|
||||||
const injectAnnotations = (emoji, annotations) => {
|
|
||||||
const availableLangs = Object.keys(annotations)
|
|
||||||
|
|
||||||
return {
|
|
||||||
...emoji,
|
|
||||||
annotations: availableLangs.reduce((acc, cur) => {
|
|
||||||
acc[cur] = annotations[cur][emoji.replacement]
|
|
||||||
return acc
|
|
||||||
}, {}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const injectRegionalIndicators = (groups) => {
|
|
||||||
groups.symbols.push(...REGIONAL_INDICATORS)
|
|
||||||
return groups
|
|
||||||
}
|
|
||||||
|
|
||||||
const instance = {
|
|
||||||
state: defaultState,
|
|
||||||
mutations: {
|
|
||||||
setInstanceOption(state, { name, value }) {
|
|
||||||
if (typeof value !== 'undefined') {
|
|
||||||
state[name] = value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setKnownDomains(state, domains) {
|
|
||||||
state.knownDomains = domains
|
|
||||||
},
|
|
||||||
setUnicodeEmojiAnnotations(state, { lang, annotations }) {
|
|
||||||
state.unicodeEmojiAnnotations[lang] = annotations
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
instanceDefaultConfig(state) {
|
|
||||||
return instanceDefaultProperties
|
|
||||||
.map((key) => [key, state[key]])
|
|
||||||
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
|
|
||||||
},
|
|
||||||
instanceDomain(state) {
|
|
||||||
return new URL(state.server).hostname
|
|
||||||
},
|
|
||||||
remoteInteractionLink(state) {
|
|
||||||
const server = state.server.endsWith('/')
|
|
||||||
? state.server.slice(0, -1)
|
|
||||||
: state.server
|
|
||||||
const link = server + REMOTE_INTERACTION_URL
|
|
||||||
|
|
||||||
return ({ statusId, nickname }) => {
|
|
||||||
if (statusId) {
|
|
||||||
return `${link}?status_id=${statusId}`
|
|
||||||
} else {
|
|
||||||
return `${link}?nickname=${nickname}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
setInstanceOption({ commit, dispatch }, { name, value }) {
|
|
||||||
commit('setInstanceOption', { name, value })
|
|
||||||
switch (name) {
|
|
||||||
case 'name':
|
|
||||||
useInterfaceStore().setPageTitle()
|
|
||||||
break
|
|
||||||
case 'shoutAvailable':
|
|
||||||
if (value) {
|
|
||||||
dispatch('initializeSocket')
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async getStaticEmoji({ commit }) {
|
|
||||||
try {
|
|
||||||
const values = (await import('/src/assets/emoji.json')).default
|
|
||||||
|
|
||||||
const emoji = Object.keys(values).reduce((res, groupId) => {
|
|
||||||
res[groupId] = values[groupId].map((e) => ({
|
|
||||||
displayText: e.slug,
|
|
||||||
imageUrl: false,
|
|
||||||
replacement: e.emoji,
|
|
||||||
}))
|
|
||||||
return res
|
|
||||||
}, {})
|
|
||||||
commit('setInstanceOption', {
|
|
||||||
name: 'emoji',
|
|
||||||
value: injectRegionalIndicators(emoji),
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("Can't load static emoji\n", e)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
loadUnicodeEmojiData({ commit, state }, language) {
|
|
||||||
const langList = ensureFinalFallback(language)
|
|
||||||
|
|
||||||
return Promise.all(
|
|
||||||
langList.map(async (lang) => {
|
|
||||||
if (!state.unicodeEmojiAnnotations[lang]) {
|
|
||||||
try {
|
|
||||||
const annotations = await loadAnnotations(lang)
|
|
||||||
commit('setUnicodeEmojiAnnotations', { lang, annotations })
|
|
||||||
} catch (e) {
|
|
||||||
console.warn(
|
|
||||||
`Error loading unicode emoji annotations for ${lang}: `,
|
|
||||||
e,
|
|
||||||
)
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
async getCustomEmoji({ commit, state }) {
|
|
||||||
try {
|
|
||||||
let res = await window.fetch('/api/v1/pleroma/emoji')
|
|
||||||
if (!res.ok) {
|
|
||||||
res = await window.fetch('/api/pleroma/emoji.json')
|
|
||||||
}
|
|
||||||
if (res.ok) {
|
|
||||||
const result = await res.json()
|
|
||||||
const values = Array.isArray(result)
|
|
||||||
? Object.assign({}, ...result)
|
|
||||||
: result
|
|
||||||
const caseInsensitiveStrCmp = (a, b) => {
|
|
||||||
const la = a.toLowerCase()
|
|
||||||
const lb = b.toLowerCase()
|
|
||||||
return la > lb ? 1 : la < lb ? -1 : 0
|
|
||||||
}
|
|
||||||
const noPackLast = (a, b) => {
|
|
||||||
const aNull = a === ''
|
|
||||||
const bNull = b === ''
|
|
||||||
if (aNull === bNull) {
|
|
||||||
return 0
|
|
||||||
} else if (aNull && !bNull) {
|
|
||||||
return 1
|
|
||||||
} else {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const byPackThenByName = (a, b) => {
|
|
||||||
const packOf = (emoji) =>
|
|
||||||
(emoji.tags.filter((k) => k.startsWith('pack:'))[0] || '').slice(
|
|
||||||
5,
|
|
||||||
)
|
|
||||||
const packOfA = packOf(a)
|
|
||||||
const packOfB = packOf(b)
|
|
||||||
return (
|
|
||||||
noPackLast(packOfA, packOfB) ||
|
|
||||||
caseInsensitiveStrCmp(packOfA, packOfB) ||
|
|
||||||
caseInsensitiveStrCmp(a.displayText, b.displayText)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const emoji = Object.entries(values)
|
|
||||||
.map(([key, value]) => {
|
|
||||||
const imageUrl = value.image_url
|
|
||||||
return {
|
|
||||||
displayText: key,
|
|
||||||
imageUrl: imageUrl ? state.server + imageUrl : value,
|
|
||||||
tags: imageUrl
|
|
||||||
? value.tags.sort((a, b) => (a > b ? 1 : 0))
|
|
||||||
: ['utf'],
|
|
||||||
replacement: `:${key}: `,
|
|
||||||
}
|
|
||||||
// Technically could use tags but those are kinda useless right now,
|
|
||||||
// should have been "pack" field, that would be more useful
|
|
||||||
})
|
|
||||||
.sort(byPackThenByName)
|
|
||||||
commit('setInstanceOption', { name: 'customEmoji', value: emoji })
|
|
||||||
} else {
|
|
||||||
throw res
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("Can't load custom emojis\n", e)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async getKnownDomains({ commit, rootState }) {
|
|
||||||
try {
|
|
||||||
const result = await apiService.fetchKnownDomains({
|
|
||||||
credentials: rootState.users.currentUser.credentials,
|
|
||||||
})
|
|
||||||
commit('setKnownDomains', result)
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("Can't load known domains\n", e)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export default instance
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue