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

86 lines
2.5 KiB
JavaScript
Raw Normal View History

2026-01-29 20:33:59 +02:00
import { mapState } from 'pinia'
2026-01-08 17:26:52 +02:00
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 BooleanSetting from '../helpers/boolean_setting.vue'
import ChoiceSetting from '../helpers/choice_setting.vue'
2025-11-24 17:06:55 +02:00
import FloatSetting from '../helpers/float_setting.vue'
2025-08-05 17:52:30 +03:00
import ProfileSettingIndicator from '../helpers/profile_setting_indicator.vue'
2020-06-07 00:15:10 +03:00
import SharedComputedObject from '../helpers/shared_computed_object.js'
2026-01-06 16:23:17 +02:00
import UnitSetting from '../helpers/unit_setting.vue'
2026-01-29 20:40:00 +02:00
import { useInstanceStore } from 'src/stores/instance.js'
2026-02-13 14:26:39 +02:00
import { useSyncConfigStore } from 'src/stores/sync_config.js'
2026-02-16 02:24:44 +02:00
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
2026-01-29 20:40:00 +02:00
import localeService from 'src/services/locale/locale.service.js'
const GeneralTab = {
2026-01-06 16:22:52 +02:00
data() {
return {
2026-01-06 16:22:52 +02:00
absoluteTime12hOptions: ['24h', '12h'].map((mode) => ({
2025-01-27 12:00:28 +02:00
key: mode,
value: mode,
2026-01-06 16:22:52 +02:00
label: this.$t(`settings.absolute_time_format_12h_${mode}`),
2025-01-27 12:00:28 +02:00
})),
2026-01-06 16:22:52 +02:00
emailLanguage: this.$store.state.users.currentUser.language || [''],
}
},
components: {
BooleanSetting,
ChoiceSetting,
UnitSetting,
2025-11-24 17:06:55 +02:00
FloatSetting,
FontControl,
InterfaceLanguageSwitcher,
2026-01-06 16:22:52 +02:00
ProfileSettingIndicator,
},
computed: {
2024-07-25 11:58:58 +03:00
language: {
2026-01-06 16:22:52 +02:00
get: function () {
2026-02-13 14:26:39 +02:00
return useSyncConfigStore().mergedConfig.interfaceLanguage
2026-01-06 16:22:52 +02:00
},
2024-07-25 11:58:58 +03:00
set: function (val) {
2026-02-16 16:58:11 +02:00
useSyncConfigStore().setSimplePrefAndSave({
path: 'interfaceLanguage',
2026-01-06 16:22:52 +02:00
value: val,
})
},
2024-07-25 11:58:58 +03:00
},
2025-08-03 18:32:18 +03:00
...SharedComputedObject(),
...mapState(useInstanceCapabilitiesStore, ['blockExpiration']),
2026-02-13 14:26:39 +02:00
...mapState(useSyncConfigStore, {
theme3hacks: (store) => store.mergedConfig.theme3hacks,
}),
},
methods: {
2026-01-06 16:22:52 +02:00
updateProfile() {
2025-08-04 13:48:09 +03:00
const params = {
2026-01-06 16:22:52 +02:00
language: localeService.internalToBackendLocaleMulti(
this.emailLanguage,
),
2025-08-04 13:48:09 +03: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) {
2026-02-16 16:58:11 +02:00
useSyncConfigStore().setSimplePrefAndSave({
path: 'theme3hacks',
2025-10-15 16:53:16 +03:00
value: {
...this.mergedConfig.theme3hacks,
fonts: {
...this.mergedConfig.theme3hacks.fonts,
2026-01-06 16:22:52 +02:00
[key]: value,
},
},
2025-10-15 16:53:16 +03:00
})
},
2026-01-06 16:22:52 +02:00
},
}
export default GeneralTab