mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-10 14:04:41 +02:00
Fix:Setting device language code
This commit is contained in:
parent
c7678da664
commit
e3aa96cbd5
2 changed files with 24 additions and 12 deletions
|
@ -123,6 +123,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-show="loading" class="w-full h-full absolute top-0 left-0 flex items-center justify-center z-10">
|
||||||
|
<ui-loading-indicator />
|
||||||
|
</div>
|
||||||
|
|
||||||
<modals-dialog v-model="showMoreMenuDialog" :items="moreMenuItems" @action="clickMenuAction" />
|
<modals-dialog v-model="showMoreMenuDialog" :items="moreMenuItems" @action="clickMenuAction" />
|
||||||
<modals-sleep-timer-length-modal v-model="showSleepTimerLengthModal" @change="sleepTimerLengthModalSelection" />
|
<modals-sleep-timer-length-modal v-model="showSleepTimerLengthModal" @change="sleepTimerLengthModalSelection" />
|
||||||
<modals-auto-sleep-timer-rewind-length-modal v-model="showAutoSleepTimerRewindLengthModal" @change="showAutoSleepTimerRewindLengthModalSelection" />
|
<modals-auto-sleep-timer-rewind-length-modal v-model="showAutoSleepTimerRewindLengthModal" @change="showAutoSleepTimerRewindLengthModalSelection" />
|
||||||
|
@ -135,6 +139,7 @@ import { Dialog } from '@capacitor/dialog'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
loading: false,
|
||||||
deviceData: null,
|
deviceData: null,
|
||||||
showMoreMenuDialog: false,
|
showMoreMenuDialog: false,
|
||||||
showSleepTimerLengthModal: false,
|
showSleepTimerLengthModal: false,
|
||||||
|
@ -329,11 +334,10 @@ export default {
|
||||||
this.hapticFeedbackUpdated(action)
|
this.hapticFeedbackUpdated(action)
|
||||||
} else if (this.moreMenuSetting === 'language') {
|
} else if (this.moreMenuSetting === 'language') {
|
||||||
this.settings.languageCode = action
|
this.settings.languageCode = action
|
||||||
this.languageOptionUpdated(action)
|
this.saveSettings()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
autoSleepTimerTimeUpdated(val) {
|
autoSleepTimerTimeUpdated(val) {
|
||||||
console.log('[settings] Auto sleep timer time=', val)
|
|
||||||
if (!val) return // invalid times return falsy
|
if (!val) return // invalid times return falsy
|
||||||
this.saveSettings()
|
this.saveSettings()
|
||||||
},
|
},
|
||||||
|
@ -341,10 +345,6 @@ export default {
|
||||||
this.$store.commit('globals/setHapticFeedback', val)
|
this.$store.commit('globals/setHapticFeedback', val)
|
||||||
this.saveSettings()
|
this.saveSettings()
|
||||||
},
|
},
|
||||||
languageOptionUpdated(val) {
|
|
||||||
this.$setLanguageCode(val)
|
|
||||||
this.saveSettings()
|
|
||||||
},
|
|
||||||
showInfo(setting) {
|
showInfo(setting) {
|
||||||
if (this.settingInfo[setting]) {
|
if (this.settingInfo[setting]) {
|
||||||
Dialog.alert({
|
Dialog.alert({
|
||||||
|
@ -428,13 +428,12 @@ export default {
|
||||||
const updatedDeviceData = await this.$db.updateDeviceSettings({ ...this.settings })
|
const updatedDeviceData = await this.$db.updateDeviceSettings({ ...this.settings })
|
||||||
if (updatedDeviceData) {
|
if (updatedDeviceData) {
|
||||||
this.$store.commit('setDeviceData', updatedDeviceData)
|
this.$store.commit('setDeviceData', updatedDeviceData)
|
||||||
this.init()
|
this.deviceData = updatedDeviceData
|
||||||
|
this.$setLanguageCode(updatedDeviceData.deviceSettings?.languageCode || 'en-us')
|
||||||
|
this.setDeviceSettings()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async init() {
|
setDeviceSettings() {
|
||||||
this.deviceData = await this.$db.getDeviceData()
|
|
||||||
this.$store.commit('setDeviceData', this.deviceData)
|
|
||||||
|
|
||||||
const deviceSettings = this.deviceData.deviceSettings || {}
|
const deviceSettings = this.deviceData.deviceSettings || {}
|
||||||
this.settings.disableAutoRewind = !!deviceSettings.disableAutoRewind
|
this.settings.disableAutoRewind = !!deviceSettings.disableAutoRewind
|
||||||
this.settings.enableAltView = !!deviceSettings.enableAltView
|
this.settings.enableAltView = !!deviceSettings.enableAltView
|
||||||
|
@ -459,6 +458,13 @@ export default {
|
||||||
this.settings.autoSleepTimerAutoRewindTime = !isNaN(deviceSettings.autoSleepTimerAutoRewindTime) ? deviceSettings.autoSleepTimerAutoRewindTime : 300000 // 5 minutes
|
this.settings.autoSleepTimerAutoRewindTime = !isNaN(deviceSettings.autoSleepTimerAutoRewindTime) ? deviceSettings.autoSleepTimerAutoRewindTime : 300000 // 5 minutes
|
||||||
|
|
||||||
this.settings.languageCode = deviceSettings.languageCode || 'en-us'
|
this.settings.languageCode = deviceSettings.languageCode || 'en-us'
|
||||||
|
},
|
||||||
|
async init() {
|
||||||
|
this.loading = true
|
||||||
|
this.deviceData = await this.$db.getDeviceData()
|
||||||
|
this.$store.commit('setDeviceData', this.deviceData)
|
||||||
|
this.setDeviceSettings()
|
||||||
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
|
@ -5,8 +5,9 @@ import { Dialog } from '@capacitor/dialog'
|
||||||
import { AbsFileSystem } from '@/plugins/capacitor'
|
import { AbsFileSystem } from '@/plugins/capacitor'
|
||||||
import { StatusBar, Style } from '@capacitor/status-bar'
|
import { StatusBar, Style } from '@capacitor/status-bar'
|
||||||
import { Clipboard } from '@capacitor/clipboard'
|
import { Clipboard } from '@capacitor/clipboard'
|
||||||
import { formatDistance, format, addDays, isDate } from 'date-fns'
|
|
||||||
import { Capacitor } from '@capacitor/core'
|
import { Capacitor } from '@capacitor/core'
|
||||||
|
import { formatDistance, format, addDays, isDate, setDefaultOptions } from 'date-fns'
|
||||||
|
import * as locale from 'date-fns/locale'
|
||||||
|
|
||||||
Vue.directive('click-outside', vClickOutside.directive)
|
Vue.directive('click-outside', vClickOutside.directive)
|
||||||
|
|
||||||
|
@ -38,6 +39,11 @@ Vue.prototype.$getAndroidSDKVersion = async () => {
|
||||||
Vue.prototype.$encodeUriPath = (path) => {
|
Vue.prototype.$encodeUriPath = (path) => {
|
||||||
return path.replace(/\\/g, '/').replace(/%/g, '%25').replace(/#/g, '%23')
|
return path.replace(/\\/g, '/').replace(/%/g, '%25').replace(/#/g, '%23')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$setDateFnsLocale = (localeString) => {
|
||||||
|
if (!locale[localeString]) return 0
|
||||||
|
return setDefaultOptions({ locale: locale[localeString] })
|
||||||
|
}
|
||||||
Vue.prototype.$dateDistanceFromNow = (unixms) => {
|
Vue.prototype.$dateDistanceFromNow = (unixms) => {
|
||||||
if (!unixms) return ''
|
if (!unixms) return ''
|
||||||
return formatDistance(unixms, Date.now(), { addSuffix: true })
|
return formatDistance(unixms, Date.now(), { addSuffix: true })
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue