audiobookshelf-app/mixins/cellularPermissionHelpers.js
FabioMich66 fc946702c1
Some checks failed
Build APK / main (push) Has been cancelled
Build iOS / Build iOS simulator app (push) Has been cancelled
Verify all i18n files are alphabetized / update_translations (push) Has been cancelled
first commit
2026-10-03 13:38:18 +02:00

42 lines
1.2 KiB
JavaScript

import { Dialog } from '@capacitor/dialog';
export default {
methods: {
async checkCellularPermission(actionType) {
if (this.$store.state.networkConnectionType !== 'cellular') return true
let permission;
if (actionType === 'download') {
permission = this.$store.getters['getCanDownloadUsingCellular']
if (permission === 'NEVER') {
this.$toast.error(this.$strings.ToastDownloadNotAllowedOnCellular)
return false
}
} else if (actionType === 'streaming') {
permission = this.$store.getters['getCanStreamingUsingCellular']
if (permission === 'NEVER') {
this.$toast.error(this.$strings.ToastStreamingNotAllowedOnCellular)
return false
}
}
if (permission === 'ASK') {
const confirmed = await this.confirmAction(actionType)
return confirmed
}
return true
},
async confirmAction(actionType) {
const message = actionType === 'download' ?
this.$strings.MessageConfirmDownloadUsingCellular :
this.$strings.MessageConfirmStreamingUsingCellular
const { value } = await Dialog.confirm({
title: this.$strings.HeaderConfirm,
message
})
return value
}
}
}