Fix:Hide download button if user does not have download permission #189

This commit is contained in:
advplyr 2022-05-22 15:49:42 -05:00
parent cb6cb5f637
commit 236fd09c94
4 changed files with 14 additions and 8 deletions

View file

@ -74,9 +74,6 @@ export default {
username() { username() {
return this.user ? this.user.username : '' return this.user ? this.user.username : ''
}, },
socketConnected() {
return this.$store.state.socketConnected
},
navItems() { navItems() {
var items = [ var items = [
{ {

View file

@ -27,7 +27,7 @@
<ui-read-icon-btn :disabled="isProcessingReadUpdate" :is-read="userIsFinished" borderless class="mx-1 mt-0.5" @click="toggleFinished" /> <ui-read-icon-btn :disabled="isProcessingReadUpdate" :is-read="userIsFinished" borderless class="mx-1 mt-0.5" @click="toggleFinished" />
<div v-if="!isIos"> <div v-if="!isIos && userCanDownload">
<span v-if="isLocal" class="material-icons-outlined px-2 text-success text-lg">audio_file</span> <span v-if="isLocal" class="material-icons-outlined px-2 text-success text-lg">audio_file</span>
<span v-else-if="!localEpisode" class="material-icons mx-1 mt-2" :class="downloadItem ? 'animate-bounce text-warning text-opacity-75 text-xl' : 'text-gray-300 text-xl'" @click="downloadClick">{{ downloadItem ? 'downloading' : 'download' }}</span> <span v-else-if="!localEpisode" class="material-icons mx-1 mt-2" :class="downloadItem ? 'animate-bounce text-warning text-opacity-75 text-xl' : 'text-gray-300 text-xl'" @click="downloadClick">{{ downloadItem ? 'downloading' : 'download' }}</span>
<span v-else class="material-icons px-2 text-success text-xl">download_done</span> <span v-else class="material-icons px-2 text-success text-xl">download_done</span>
@ -69,6 +69,9 @@ export default {
mediaType() { mediaType() {
return 'podcast' return 'podcast'
}, },
userCanDownload() {
return this.$store.getters['user/getUserCanDownload']
},
audioFile() { audioFile() {
return this.episode.audioFile return this.episode.audioFile
}, },

View file

@ -49,7 +49,7 @@
<span class="material-icons">auto_stories</span> <span class="material-icons">auto_stories</span>
<span v-if="!showPlay" class="px-2 text-base">Read {{ ebookFormat }}</span> <span v-if="!showPlay" class="px-2 text-base">Read {{ ebookFormat }}</span>
</ui-btn> </ui-btn>
<ui-btn v-if="user && showPlay && !hasLocal" :color="downloadItem ? 'warning' : 'primary'" class="flex items-center justify-center mr-2" :padding-x="2" @click="downloadClick"> <ui-btn v-if="showDownload" :color="downloadItem ? 'warning' : 'primary'" class="flex items-center justify-center mr-2" :padding-x="2" @click="downloadClick">
<span class="material-icons" :class="downloadItem ? 'animate-pulse' : ''">{{ downloadItem ? 'downloading' : 'download' }}</span> <span class="material-icons" :class="downloadItem ? 'animate-pulse' : ''">{{ downloadItem ? 'downloading' : 'download' }}</span>
</ui-btn> </ui-btn>
<ui-read-icon-btn v-if="!isPodcast" :disabled="isProcessingReadUpdate" :is-read="userIsFinished" class="flex items-center justify-center" @click="toggleFinished" /> <ui-read-icon-btn v-if="!isPodcast" :disabled="isProcessingReadUpdate" :is-read="userIsFinished" class="flex items-center justify-center" @click="toggleFinished" />
@ -117,6 +117,9 @@ export default {
isIos() { isIos() {
return this.$platform === 'ios' return this.$platform === 'ios'
}, },
userCanDownload() {
return this.$store.getters['user/getUserCanDownload']
},
isLocal() { isLocal() {
return this.libraryItem.isLocal return this.libraryItem.isLocal
}, },
@ -235,6 +238,9 @@ export default {
showRead() { showRead() {
return this.ebookFile && this.ebookFormat !== 'pdf' return this.ebookFile && this.ebookFormat !== 'pdf'
}, },
showDownload() {
return this.user && this.userCanDownload && this.showPlay && !this.hasLocal
},
ebookFile() { ebookFile() {
return this.media.ebookFile return this.media.ebookFile
}, },
@ -242,9 +248,6 @@ export default {
if (!this.ebookFile) return null if (!this.ebookFile) return null
return this.ebookFile.ebookFormat return this.ebookFile.ebookFormat
}, },
hasStoragePermission() {
return this.$store.state.hasStoragePermission
},
downloadItem() { downloadItem() {
return this.$store.getters['globals/getDownloadItem'](this.libraryItemId) return this.$store.getters['globals/getDownloadItem'](this.libraryItemId)
}, },

View file

@ -35,6 +35,9 @@ export const getters = {
}, },
getUserSetting: (state) => (key) => { getUserSetting: (state) => (key) => {
return state.settings ? state.settings[key] || null : null return state.settings ? state.settings[key] || null : null
},
getUserCanDownload: (state) => {
return state.user && state.user.permissions ? !!state.user.permissions.download : false
} }
} }