mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-05 18:45:47 +02:00
Improvements and fixes on the cellular permissions
This commit is contained in:
parent
574dda5286
commit
4ad54f34fe
9 changed files with 94 additions and 72 deletions
42
mixins/cellularPermissionHelpers.js
Normal file
42
mixins/cellularPermissionHelpers.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
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: 'Confirm',
|
||||
message
|
||||
})
|
||||
return value
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue