Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Add a low feedback mode #967

Merged
merged 16 commits into from Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/modals/ItemMoreMenuModal.vue
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
10 changes: 1 addition & 9 deletions components/tables/podcast/EpisodeRow.vue
Expand Up @@ -58,7 +58,6 @@
</template>

<script>
import { Dialog } from '@capacitor/dialog'
import { AbsFileSystem, AbsDownloader } from '@/plugins/capacitor'

export default {
Expand Down Expand Up @@ -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 = {
Expand Down
23 changes: 10 additions & 13 deletions components/tables/podcast/LatestEpisodeRow.vue
Expand Up @@ -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>

Expand All @@ -58,7 +58,6 @@
</template>

<script>
import { Dialog } from '@capacitor/dialog'
import { AbsFileSystem, AbsDownloader } from '@/plugins/capacitor'

export default {
Expand All @@ -78,6 +77,7 @@ export default {
data() {
return {
isProcessingReadUpdate: false,
pendingDownload: false,
processing: false
}
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion components/widgets/DownloadProgressIndicator.vue
Expand Up @@ -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)
}

Expand Down
37 changes: 36 additions & 1 deletion pages/bookshelf/latest.vue
Expand Up @@ -16,7 +16,7 @@ export default {
recentEpisodes: [],
totalEpisodes: 0,
currentPage: 0,
localEpisodeMap: {},
localLibraryItems: [],
isLocal: false,
loadedLibraryId: null
}
Expand All @@ -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: {
Expand Down Expand Up @@ -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>
11 changes: 1 addition & 10 deletions pages/item/_id/_episode/index.vue
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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) => {
Expand Down
7 changes: 0 additions & 7 deletions pages/item/_id/index.vue
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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) {
Expand Down