Merge pull request #967 from tonyedwardspz/master

Feature - Add a low feedback mode
This commit is contained in:
advplyr 2023-12-09 15:14:52 -06:00 committed by GitHub
commit 52701048ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 43 deletions

View file

@ -388,7 +388,6 @@ export default {
if (value) {
const res = await AbsFileSystem.deleteTrackFromItem({ id: this.localLibraryItemId, trackLocalFileId: localFile.id, trackContentUrl: localEpisodeAudioTrack.contentUrl })
if (res?.id) {
this.$toast.success('Deleted episode successfully')
if (this.isLocal) {
// If this is local episode then redirect to server episode when available
if (this.serverEpisodeId) {
@ -414,7 +413,6 @@ export default {
if (value) {
const res = await AbsFileSystem.deleteItem(this.localLibraryItem)
if (res?.success) {
this.$toast.success('Deleted successfully')
if (this.isLocal) {
// If local then redirect to server version when available
if (this.serverLibraryItemId) {

View file

@ -58,7 +58,6 @@
</template>
<script>
import { Dialog } from '@capacitor/dialog'
import { AbsFileSystem, AbsDownloader } from '@/plugins/capacitor'
export default {
@ -210,14 +209,7 @@ export default {
console.log('Local folder', JSON.stringify(localFolder))
var startDownloadMessage = `Start download for "${this.title}" to folder ${localFolder.name}?`
const { value } = await Dialog.confirm({
title: 'Confirm',
message: startDownloadMessage
})
if (value) {
this.startDownload(localFolder)
}
this.startDownload(localFolder)
},
async startDownload(localFolder) {
var payload = {

View file

@ -41,7 +41,7 @@
<div v-if="userCanDownload">
<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.5 mt-2 text-xl" :class="downloadItem ? 'animate-bounce text-warning text-opacity-75' : ''" @click.stop="downloadClick">{{ downloadItem ? 'downloading' : 'download' }}</span>
<span v-else-if="!localEpisode" class="material-icons mx-1.5 mt-2 text-xl" :class="downloadItem || pendingDownload ? 'animate-bounce text-warning text-opacity-75' : ''" @click.stop="downloadClick">{{ downloadItem || pendingDownload ? 'downloading' : 'download' }}</span>
<span v-else class="material-icons px-2 text-success text-xl">download_done</span>
</div>
@ -58,7 +58,6 @@
</template>
<script>
import { Dialog } from '@capacitor/dialog'
import { AbsFileSystem, AbsDownloader } from '@/plugins/capacitor'
export default {
@ -78,6 +77,7 @@ export default {
data() {
return {
isProcessingReadUpdate: false,
pendingDownload: false,
processing: false
}
},
@ -175,14 +175,16 @@ export default {
return folderObj
},
async downloadClick() {
if (this.downloadItem) return
if (this.downloadItem || this.pendingDownload) return
this.pendingDownload = true
await this.$hapticsImpact()
if (this.isIos) {
// no local folders on iOS
this.startDownload()
await this.startDownload()
} else {
this.download()
await this.download()
}
this.pendingDownload = false
},
async download(selectedLocalFolder = null) {
let localFolder = selectedLocalFolder
@ -216,14 +218,7 @@ export default {
console.log('Local folder', JSON.stringify(localFolder))
var startDownloadMessage = `Start download for "${this.title}" to folder ${localFolder.name}?`
const { value } = await Dialog.confirm({
title: 'Confirm',
message: startDownloadMessage
})
if (value) {
this.startDownload(localFolder)
}
return this.startDownload(localFolder)
},
async startDownload(localFolder) {
var payload = {
@ -238,6 +233,8 @@ export default {
var errorMsg = downloadRes.error || 'Unknown error'
console.error('Download error', errorMsg)
this.$toast.error(errorMsg)
} else {
console.log('Download completed', JSON.stringify(downloadRes))
}
},
async playClick() {

View file

@ -56,7 +56,6 @@ export default {
if (!data.localLibraryItem) {
this.$toast.error(this.$strings.MessageItemDownloadCompleteFailedToCreate)
} else {
this.$toast.success(`Item "${data.localLibraryItem.media.metadata.title}" download finished`)
this.$eventBus.$emit('new-local-library-item', data.localLibraryItem)
}

View file

@ -16,7 +16,7 @@ export default {
recentEpisodes: [],
totalEpisodes: 0,
currentPage: 0,
localEpisodeMap: {},
localLibraryItems: [],
isLocal: false,
loadedLibraryId: null
}
@ -25,6 +25,24 @@ export default {
computed: {
currentLibraryId() {
return this.$store.state.libraries.currentLibraryId
},
localEpisodes() {
const episodes = []
this.localLibraryItems.forEach((li) => {
if (li.media.episodes?.length) {
episodes.push(...li.media.episodes)
}
})
return episodes
},
localEpisodeMap() {
var epmap = {}
this.localEpisodes.forEach((localEp) => {
if (localEp.serverEpisodeId) {
epmap[localEp.serverEpisodeId] = localEp
}
})
return epmap
}
},
methods: {
@ -61,14 +79,31 @@ export default {
this.$router.replace('/bookshelf')
}
}
},
async loadLocalPodcastLibraryItems() {
this.localLibraryItems = await this.$db.getLocalLibraryItems('podcast')
},
newLocalLibraryItem(item) {
if (item.mediaType !== 'podcast') {
return
}
const matchingLocalLibraryItem = this.localLibraryItems.find((lli) => lli.id === item.id)
if (matchingLocalLibraryItem) {
matchingLocalLibraryItem.media.episodes = item.media.episodes
} else {
this.localLibraryItems.push(item)
}
}
},
mounted() {
this.loadRecentEpisodes()
this.loadLocalPodcastLibraryItems()
this.$eventBus.$on('library-changed', this.libraryChanged)
this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
},
beforeDestroy() {
this.$eventBus.$off('library-changed', this.libraryChanged)
this.$eventBus.$off('new-local-library-item', this.newLocalLibraryItem)
}
}
</script>

View file

@ -316,7 +316,6 @@ export default {
if (value) {
const res = await AbsFileSystem.deleteTrackFromItem({ id: this.localLibraryItemId, trackLocalFileId: localFile.id, trackContentUrl: localEpisodeAudioTrack.contentUrl })
if (res?.id) {
this.$toast.success('Deleted episode successfully')
if (this.isLocal) {
// If this is local episode then redirect to server episode when available
if (this.serverEpisodeId) {
@ -398,14 +397,7 @@ export default {
console.log('Local folder', JSON.stringify(localFolder))
const startDownloadMessage = `Start download for "${this.title}" to folder ${localFolder.name}?`
const { value } = await Dialog.confirm({
title: 'Confirm',
message: startDownloadMessage
})
if (value) {
this.startDownload(localFolder)
}
this.startDownload(localFolder)
},
async selectFolder() {
const folderObj = await AbsFileSystem.selectFolder({ mediaType: this.mediaType })
@ -518,7 +510,6 @@ export default {
this.$nativeHttp
.delete(`/api/podcasts/${this.serverLibraryItemId}/episode/${this.serverEpisodeId}?hard=1`)
.then(() => {
this.$toast.success('Episode deleted from server')
this.$router.replace(`/item/${this.serverLibraryItemId}`)
})
.catch((error) => {

View file

@ -40,12 +40,6 @@
<div v-else-if="currentServerConnectionConfigId && !isLocalMatchingConnectionConfig" class="w-full rounded-md bg-warning/10 border border-warning p-4">
<p class="text-sm">Media is linked to a different server connection config. Downloaded User Id: {{ localLibraryItem.serverUserId }}. Downloaded Server Address: {{ localLibraryItem.serverAddress }}. Currently connected User Id: {{ user.id }}. Currently connected server address: {{ currentServerAddress }}.</p>
</div>
<div v-else-if="isLocalMatchingConnectionConfig" class="w-full rounded-md bg-success/10 border border-success p-4">
<p class="text-sm">{{ $strings.MessageMediaLinkedToThisServer }}</p>
</div>
<div v-else-if="isLocal && libraryItem.serverAddress" class="w-full rounded-md bg-slate-300/10 border border-slate-300 p-4">
<p class="text-sm">{{ $getString('MessageMediaLinkedToServer', [libraryItem.serverAddress]) }}</p>
</div>
</div>
<!-- action buttons -->
@ -615,7 +609,6 @@ export default {
}
console.log('Local folder', JSON.stringify(localFolder))
let startDownloadMessage = `Start download for "${this.title}" with ${this.numTracks} audio track${this.numTracks == 1 ? '' : 's'} to folder ${localFolder.name}?`
if (!this.isIos && this.showRead) {
if (this.numTracks > 0) {