pleroma-fe/src/components/settings_modal/tabs/composing_tab.js

191 lines
5.6 KiB
JavaScript
Raw Normal View History

2025-11-24 17:06:55 +02:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
2026-01-06 16:23:17 +02:00
faDatabase,
2025-11-24 17:06:55 +02:00
faGlobe,
faMessage,
faPenAlt,
2026-01-06 16:22:52 +02:00
faSliders,
2025-11-24 17:06:55 +02:00
} from '@fortawesome/free-solid-svg-icons'
2026-01-06 16:23:17 +02:00
import FontControl from 'src/components/font_control/font_control.vue'
import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue'
import ScopeSelector from 'src/components/scope_selector/scope_selector.vue'
import Select from 'src/components/select/select.vue'
import localeService from 'src/services/locale/locale.service.js'
import { cacheKey, clearCache, emojiCacheKey } from 'src/services/sw/sw.js'
import { mapState } from 'vuex'
import BooleanSetting from '../helpers/boolean_setting.vue'
import ChoiceSetting from '../helpers/choice_setting.vue'
import FloatSetting from '../helpers/float_setting.vue'
import IntegerSetting from '../helpers/integer_setting.vue'
import ProfileSettingIndicator from '../helpers/profile_setting_indicator.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import UnitSetting from '../helpers/unit_setting.vue'
2025-11-24 17:06:55 +02:00
2026-01-06 16:22:52 +02:00
library.add(faGlobe, faMessage, faPenAlt, faDatabase, faSliders)
2025-11-24 17:06:55 +02:00
const ComposingTab = {
props: {
parentCollapsed: {
required: true,
2026-01-06 16:22:52 +02:00
type: Boolean,
},
2025-11-24 17:06:55 +02:00
},
2026-01-06 16:22:52 +02:00
data() {
2025-11-24 17:06:55 +02:00
return {
2026-01-06 16:22:52 +02:00
subjectLineOptions: ['email', 'noop', 'masto'].map((mode) => ({
2025-11-24 17:06:55 +02:00
key: mode,
value: mode,
2026-01-06 16:22:52 +02:00
label: this.$t(
`settings.subject_line_${mode === 'masto' ? 'mastodon' : mode}`,
),
2025-11-24 17:06:55 +02:00
})),
2026-01-06 16:22:52 +02:00
conversationDisplayOptions: ['tree', 'linear'].map((mode) => ({
2025-11-24 17:06:55 +02:00
key: mode,
value: mode,
2026-01-06 16:22:52 +02:00
label: this.$t(`settings.conversation_display_${mode}`),
2025-11-24 17:06:55 +02:00
})),
2026-01-06 16:22:52 +02:00
absoluteTime12hOptions: ['24h', '12h'].map((mode) => ({
2025-11-24 17:06:55 +02:00
key: mode,
value: mode,
2026-01-06 16:22:52 +02:00
label: this.$t(`settings.absolute_time_format_12h_${mode}`),
2025-11-24 17:06:55 +02:00
})),
2026-01-06 16:22:52 +02:00
conversationOtherRepliesButtonOptions: ['below', 'inside'].map(
(mode) => ({
key: mode,
value: mode,
label: this.$t(`settings.conversation_other_replies_button_${mode}`),
}),
),
mentionLinkDisplayOptions: ['short', 'full_for_remote', 'full'].map(
(mode) => ({
key: mode,
value: mode,
label: this.$t(`settings.mention_link_display_${mode}`),
}),
),
userPopoverAvatarActionOptions: ['close', 'zoom', 'open'].map((mode) => ({
2025-11-24 17:06:55 +02:00
key: mode,
value: mode,
2026-01-06 16:22:52 +02:00
label: this.$t(`settings.user_popover_avatar_action_${mode}`),
2025-11-24 17:06:55 +02:00
})),
2026-01-06 16:22:52 +02:00
unsavedPostActionOptions: ['save', 'discard', 'confirm'].map((mode) => ({
2025-11-24 17:06:55 +02:00
key: mode,
value: mode,
2026-01-06 16:22:52 +02:00
label: this.$t(`settings.unsaved_post_action_${mode}`),
2025-11-24 17:06:55 +02:00
})),
loopSilentAvailable:
2026-01-06 16:22:52 +02:00
// Firefox
Object.getOwnPropertyDescriptor(
HTMLVideoElement.prototype,
'mozHasAudio',
) ||
// Chrome-likes
Object.getOwnPropertyDescriptor(
HTMLMediaElement.prototype,
'webkitAudioDecodedByteCount',
) ||
// Future spec, still not supported in Nightly 63 as of 08/2018
Object.getOwnPropertyDescriptor(
HTMLMediaElement.prototype,
'audioTracks',
),
emailLanguage: this.$store.state.users.currentUser.language || [''],
2025-11-24 17:06:55 +02:00
}
},
components: {
BooleanSetting,
ChoiceSetting,
IntegerSetting,
FloatSetting,
UnitSetting,
InterfaceLanguageSwitcher,
ProfileSettingIndicator,
ScopeSelector,
Select,
2026-01-06 16:22:52 +02:00
FontControl,
2025-11-24 17:06:55 +02:00
},
computed: {
2026-01-06 16:22:52 +02:00
postFormats() {
2025-11-24 17:06:55 +02:00
return this.$store.state.instance.postFormats || []
},
2026-01-06 16:22:52 +02:00
postContentOptions() {
return this.postFormats.map((format) => ({
2025-11-24 17:06:55 +02:00
key: format,
value: format,
2026-01-06 16:22:52 +02:00
label: this.$t(`post_status.content_type["${format}"]`),
2025-11-24 17:06:55 +02:00
}))
},
language: {
2026-01-06 16:22:52 +02:00
get: function () {
return this.$store.getters.mergedConfig.interfaceLanguage
},
2025-11-24 17:06:55 +02:00
set: function (val) {
2026-01-06 16:22:52 +02:00
this.$store.dispatch('setOption', {
name: 'interfaceLanguage',
value: val,
})
},
2025-11-24 17:06:55 +02:00
},
...SharedComputedObject(),
...mapState({
2026-01-06 16:22:52 +02:00
blockExpirationSupported: (state) => state.instance.blockExpiration,
}),
2025-11-24 17:06:55 +02:00
},
methods: {
2026-01-06 16:22:52 +02:00
changeDefaultScope(value) {
2025-11-24 17:06:55 +02:00
this.$store.dispatch('setProfileOption', { name: 'defaultScope', value })
},
2026-01-06 16:22:52 +02:00
clearCache(key) {
2025-11-24 17:06:55 +02:00
clearCache(key)
.then(() => {
this.$store.dispatch('settingsSaved', { success: true })
})
2026-01-06 16:22:52 +02:00
.catch((error) => {
2025-11-24 17:06:55 +02:00
this.$store.dispatch('settingsSaved', { error })
})
},
2026-01-06 16:22:52 +02:00
tooSmall() {
2025-11-24 17:06:55 +02:00
this.$emit('tooSmall')
},
2026-01-06 16:22:52 +02:00
tooBig() {
2025-11-24 17:06:55 +02:00
this.$emit('tooBig')
},
2026-01-06 16:22:52 +02:00
getNavMode() {
2025-11-24 17:06:55 +02:00
return this.$refs.tabSwitcher.getNavMode()
},
2026-01-06 16:22:52 +02:00
clearAssetCache() {
2025-11-24 17:06:55 +02:00
this.clearCache(cacheKey)
},
2026-01-06 16:22:52 +02:00
clearEmojiCache() {
2025-11-24 17:06:55 +02:00
this.clearCache(emojiCacheKey)
},
2026-01-06 16:22:52 +02:00
updateProfile() {
2025-11-24 17:06:55 +02:00
const params = {
2026-01-06 16:22:52 +02:00
language: localeService.internalToBackendLocaleMulti(
this.emailLanguage,
),
2025-11-24 17:06:55 +02:00
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
.then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)
})
},
2026-01-06 16:22:52 +02:00
updateFont(key, value) {
2025-11-24 17:06:55 +02:00
this.$store.dispatch('setOption', {
name: 'theme3hacks',
value: {
...this.mergedConfig.theme3hacks,
fonts: {
...this.mergedConfig.theme3hacks.fonts,
2026-01-06 16:22:52 +02:00
[key]: value,
},
},
2025-11-24 17:06:55 +02:00
})
},
2026-01-06 16:22:52 +02:00
},
2025-11-24 17:06:55 +02:00
}
export default ComposingTab