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

140 lines
4.6 KiB
JavaScript
Raw Normal View History

2025-08-03 18:32:18 +03:00
import { mapState } from 'vuex'
import BooleanSetting from '../helpers/boolean_setting.vue'
import ChoiceSetting from '../helpers/choice_setting.vue'
import ScopeSelector from 'src/components/scope_selector/scope_selector.vue'
2022-03-07 20:02:53 -05:00
import IntegerSetting from '../helpers/integer_setting.vue'
import FloatSetting from '../helpers/float_setting.vue'
2024-06-13 02:22:47 +03:00
import UnitSetting from '../helpers/unit_setting.vue'
import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue'
2025-07-09 18:37:05 +03:00
import Select from 'src/components/select/select.vue'
2020-06-07 00:15:10 +03:00
import SharedComputedObject from '../helpers/shared_computed_object.js'
2025-07-09 18:37:05 +03:00
2025-08-04 13:48:09 +03:00
import localeService from 'src/services/locale/locale.service.js'
2024-08-23 00:31:03 -04:00
import { clearCache, cacheKey, emojiCacheKey } from 'src/services/sw/sw.js'
2020-10-20 21:03:46 +03:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faGlobe
2020-10-20 21:03:46 +03:00
} from '@fortawesome/free-solid-svg-icons'
library.add(
faGlobe
2020-10-20 21:03:46 +03:00
)
const GeneralTab = {
data () {
return {
subjectLineOptions: ['email', 'noop', 'masto'].map(mode => ({
key: mode,
value: mode,
label: this.$t(`settings.subject_line_${mode === 'masto' ? 'mastodon' : mode}`)
})),
conversationDisplayOptions: ['tree', 'linear'].map(mode => ({
2021-08-06 20:18:27 -04:00
key: mode,
value: mode,
label: this.$t(`settings.conversation_display_${mode}`)
})),
2025-01-27 12:00:28 +02:00
absoluteTime12hOptions: ['24h', '12h'].map(mode => ({
key: mode,
value: mode,
label: this.$t(`settings.absolute_time_format_12h_${mode}`)
})),
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 => ({
key: mode,
value: mode,
label: this.$t(`settings.user_popover_avatar_action_${mode}`)
})),
unsavedPostActionOptions: ['save', 'discard', 'confirm'].map(mode => ({
key: mode,
value: mode,
label: this.$t(`settings.unsaved_post_action_${mode}`)
})),
loopSilentAvailable:
// 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
2020-05-25 03:43:55 +03:00
Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'audioTracks')
}
},
components: {
BooleanSetting,
ChoiceSetting,
2022-03-07 20:02:53 -05:00
IntegerSetting,
FloatSetting,
UnitSetting,
InterfaceLanguageSwitcher,
ScopeSelector,
2025-07-09 18:37:05 +03:00
Select
},
computed: {
postFormats () {
return this.$store.state.instance.postFormats || []
},
postContentOptions () {
return this.postFormats.map(format => ({
key: format,
value: format,
label: this.$t(`post_status.content_type["${format}"]`)
}))
},
2024-07-25 11:58:58 +03:00
language: {
get: function () { return this.$store.getters.mergedConfig.interfaceLanguage },
set: function (val) {
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
}
},
2024-12-23 04:15:24 +02:00
instanceShoutboxPresent () { return this.$store.state.instance.shoutAvailable },
instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel },
2025-08-03 18:32:18 +03:00
...SharedComputedObject(),
...mapState({
blockExpirationSupported: state => state.instance.blockExpiration,
})
},
methods: {
changeDefaultScope (value) {
this.$store.dispatch('setProfileOption', { name: 'defaultScope', value })
2024-08-23 00:31:03 -04:00
},
clearCache (key) {
clearCache(key)
2025-03-04 19:37:24 -05:00
.then(() => {
2024-08-23 00:31:03 -04:00
this.$store.dispatch('settingsSaved', { success: true })
})
.catch(error => {
this.$store.dispatch('settingsSaved', { error })
})
},
clearAssetCache () {
this.clearCache(cacheKey)
},
clearEmojiCache () {
this.clearCache(emojiCacheKey)
2025-08-04 13:48:09 +03:00
},
updateProfile () {
const params = {
language: localeService.internalToBackendLocaleMulti(this.emailLanguage)
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
.then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)
})
},
}
}
export default GeneralTab