From c18f722929a07ad200a7b8a72788ac8fb1038e80 Mon Sep 17 00:00:00 2001 From: Maaz Hassan Date: Wed, 27 Dec 2023 09:41:52 +0000 Subject: [PATCH] Add: "Play Next" button for book and podcast cards --- client/components/cards/LazyBookCard.vue | 37 +++++++++++++++++++++++- client/store/index.js | 9 ++++++ client/strings/cs.json | 1 + client/strings/da.json | 1 + client/strings/de.json | 3 +- client/strings/en-us.json | 1 + client/strings/es.json | 1 + client/strings/fr.json | 1 + client/strings/gu.json | 1 + client/strings/hi.json | 1 + client/strings/hr.json | 1 + client/strings/it.json | 1 + client/strings/lt.json | 1 + client/strings/nl.json | 1 + client/strings/no.json | 1 + client/strings/pl.json | 1 + client/strings/ru.json | 1 + client/strings/sv.json | 1 + client/strings/zh-cn.json | 1 + 19 files changed, 63 insertions(+), 2 deletions(-) diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index c4d1345da..d9ff5b04e 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -463,7 +463,11 @@ export default { if (!this.isQueued) { items.push({ func: 'addToQueue', - text: this.$strings.ButtonQueueAddItem + text: this.$strings.ButtonQueuePlayNext + }, + { + func: 'playNext', + text: this.$strings.ButtonQueuePlayNext }) } else if (!this.isStreaming) { items.push({ @@ -542,6 +546,10 @@ export default { items.push({ func: 'addToQueue', text: this.$strings.ButtonQueueAddItem + }, + { + func: 'playNext', + text: this.$strings.ButtonQueuePlayNext }) } else if (!this.isStreaming) { items.push({ @@ -830,6 +838,33 @@ export default { } this.store.commit('addItemToQueue', queueItem) }, + playNext() { + var queueItem = {} + if (this.recentEpisode) { + queueItem = { + libraryItemId: this.libraryItemId, + libraryId: this.libraryId, + episodeId: this.recentEpisode.id, + title: this.recentEpisode.title, + subtitle: this.mediaMetadata.title, + caption: this.recentEpisode.publishedAt ? `Published ${this.$formatDate(this.recentEpisode.publishedAt, this.dateFormat)}` : 'Unknown publish date', + duration: this.recentEpisode.audioFile.duration || null, + coverPath: this.media.coverPath || null + } + } else { + queueItem = { + libraryItemId: this.libraryItemId, + libraryId: this.libraryId, + episodeId: null, + title: this.title, + subtitle: this.author, + caption: '', + duration: this.media.duration || null, + coverPath: this.media.coverPath || null + } + } + this.store.commit('addItemToTopOfQueue', queueItem) + }, removeFromQueue() { const episodeId = this.recentEpisode ? this.recentEpisode.id : null this.store.commit('removeItemFromQueue', { libraryItemId: this.libraryItemId, episodeId }) diff --git a/client/store/index.js b/client/store/index.js index ed7c35b61..ac35860c1 100644 --- a/client/store/index.js +++ b/client/store/index.js @@ -188,6 +188,15 @@ export const mutations = { state.playerQueueItems.push(item) } }, + addItemToTopOfQueue(state, item) { + const exists = state.playerQueueItems.some(i => { + if (!i.episodeId) return i.libraryItemId === item.libraryItemId + return i.libraryItemId === item.libraryItemId && i.episodeId === item.episodeId + }) + if (!exists) { + state.playerQueueItems.splice(1, 0, item) + } + }, setPlayerQueueAutoPlay(state, autoPlay) { state.playerQueueAutoPlay = !!autoPlay localStorage.setItem('playerQueueAutoPlay', !!autoPlay ? '1' : '0') diff --git a/client/strings/cs.json b/client/strings/cs.json index bac376d87..c9bf88b22 100644 --- a/client/strings/cs.json +++ b/client/strings/cs.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Vyčistit mezipaměť položek", "ButtonPurgeMediaProgress": "Vyčistit průběh médií", "ButtonQueueAddItem": "Přidat do fronty", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Odstranit z fronty", "ButtonQuickMatch": "Rychlé přiřazení", "ButtonRead": "Číst", diff --git a/client/strings/da.json b/client/strings/da.json index 3dd611d9e..5814a4f82 100644 --- a/client/strings/da.json +++ b/client/strings/da.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Ryd elementcache", "ButtonPurgeMediaProgress": "Ryd Medieforløb", "ButtonQueueAddItem": "Tilføj til kø", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Fjern fra kø", "ButtonQuickMatch": "Hurtig Match", "ButtonRead": "Læs", diff --git a/client/strings/de.json b/client/strings/de.json index 20da77c19..2afbdefa2 100644 --- a/client/strings/de.json +++ b/client/strings/de.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Lösche Medien-Zwischenspeicher", "ButtonPurgeMediaProgress": "Lösche Hörfortschritte", "ButtonQueueAddItem": "Zur Warteschlange hinzufügen", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Aus der Warteschlange entfernen", "ButtonQuickMatch": "Schnellabgleich", "ButtonRead": "Lese", @@ -750,4 +751,4 @@ "ToastSocketFailedToConnect": "Verbindung zum WebSocket fehlgeschlagen", "ToastUserDeleteFailed": "Benutzer konnte nicht gelöscht werden", "ToastUserDeleteSuccess": "Benutzer gelöscht" -} +} \ No newline at end of file diff --git a/client/strings/en-us.json b/client/strings/en-us.json index f69175fde..d609cecc8 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Purge Items Cache", "ButtonPurgeMediaProgress": "Purge Media Progress", "ButtonQueueAddItem": "Add to queue", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Remove from queue", "ButtonQuickMatch": "Quick Match", "ButtonRead": "Read", diff --git a/client/strings/es.json b/client/strings/es.json index cefeb8f87..cf95535bd 100644 --- a/client/strings/es.json +++ b/client/strings/es.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Purgar Elementos de Cache", "ButtonPurgeMediaProgress": "Purgar Progreso de Multimedia", "ButtonQueueAddItem": "Agregar a la Fila", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Remover de la Fila", "ButtonQuickMatch": "Encontrar Rápido", "ButtonRead": "Leer", diff --git a/client/strings/fr.json b/client/strings/fr.json index 86a646025..37a632058 100644 --- a/client/strings/fr.json +++ b/client/strings/fr.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Purger le cache des articles", "ButtonPurgeMediaProgress": "Purger la progression des médias", "ButtonQueueAddItem": "Ajouter à la liste de lecture", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Supprimer de la liste de lecture", "ButtonQuickMatch": "Recherche rapide", "ButtonRead": "Lire", diff --git a/client/strings/gu.json b/client/strings/gu.json index 24c874eba..2ad83706f 100644 --- a/client/strings/gu.json +++ b/client/strings/gu.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "વસ્તુઓનો Cache કાઢી નાખો", "ButtonPurgeMediaProgress": "બધું સાંભળ્યું કાઢી નાખો", "ButtonQueueAddItem": "કતારમાં ઉમેરો", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "કતારથી કાઢી નાખો", "ButtonQuickMatch": "ઝડપી મેળ ખવડાવો", "ButtonRead": "વાંચો", diff --git a/client/strings/hi.json b/client/strings/hi.json index e7ec61556..087a25a46 100644 --- a/client/strings/hi.json +++ b/client/strings/hi.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "आइटम Cache मिटाएं", "ButtonPurgeMediaProgress": "अभी तक सुना हुआ सब हटा दे", "ButtonQueueAddItem": "क़तार में जोड़ें", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "कतार से हटाएं", "ButtonQuickMatch": "जल्दी से समानता की तलाश करें", "ButtonRead": "पढ़ लिया", diff --git a/client/strings/hr.json b/client/strings/hr.json index edefcf53c..f12cf4c20 100644 --- a/client/strings/hr.json +++ b/client/strings/hr.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Isprazni Items Cache", "ButtonPurgeMediaProgress": "Purge Media Progress", "ButtonQueueAddItem": "Add to queue", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Remove from queue", "ButtonQuickMatch": "Brzi match", "ButtonRead": "Pročitaj", diff --git a/client/strings/it.json b/client/strings/it.json index 0860e83f3..fe6e46d36 100644 --- a/client/strings/it.json +++ b/client/strings/it.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Elimina la Cache selezionata", "ButtonPurgeMediaProgress": "Elimina info dei media ascoltati", "ButtonQueueAddItem": "Aggiungi alla Coda", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Rimuovi dalla Coda", "ButtonQuickMatch": "Controlla Metadata Auto", "ButtonRead": "Leggi", diff --git a/client/strings/lt.json b/client/strings/lt.json index 94067198d..e6c0f822f 100644 --- a/client/strings/lt.json +++ b/client/strings/lt.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Valyti elementų saugyklą", "ButtonPurgeMediaProgress": "Valyti medijos progresą", "ButtonQueueAddItem": "Pridėti į eilę", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Pašalinti iš eilės", "ButtonQuickMatch": "Greitas pritaikymas", "ButtonRead": "Skaityti", diff --git a/client/strings/nl.json b/client/strings/nl.json index 19a5c35a8..0d6ee452f 100644 --- a/client/strings/nl.json +++ b/client/strings/nl.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Onderdelen-cache legen", "ButtonPurgeMediaProgress": "Mediavoortgang legen", "ButtonQueueAddItem": "In wachtrij zetten", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Uit wachtrij verwijderen", "ButtonQuickMatch": "Snelle match", "ButtonRead": "Lees", diff --git a/client/strings/no.json b/client/strings/no.json index 37cbc7a81..1d7650a9a 100644 --- a/client/strings/no.json +++ b/client/strings/no.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Tøm mellomlager", "ButtonPurgeMediaProgress": "Slett medie fremgang", "ButtonQueueAddItem": "Legg til kø", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Fjern fra kø", "ButtonQuickMatch": "Kjapt søk", "ButtonRead": "Les", diff --git a/client/strings/pl.json b/client/strings/pl.json index 86e292741..09c000755 100644 --- a/client/strings/pl.json +++ b/client/strings/pl.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Wyczyść dane tymczasowe pozycji", "ButtonPurgeMediaProgress": "Wyczyść postęp", "ButtonQueueAddItem": "Dodaj do kolejki", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Usuń z kolejki", "ButtonQuickMatch": "Szybkie dopasowanie", "ButtonRead": "Czytaj", diff --git a/client/strings/ru.json b/client/strings/ru.json index 4d26c4aae..4c6262d80 100644 --- a/client/strings/ru.json +++ b/client/strings/ru.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Очистить кэш элементов", "ButtonPurgeMediaProgress": "Очистить прогресс медиа", "ButtonQueueAddItem": "Добавить в очередь", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Удалить из очереди", "ButtonQuickMatch": "Быстрый поиск", "ButtonRead": "Читать", diff --git a/client/strings/sv.json b/client/strings/sv.json index 1d71fce5a..934fe0412 100644 --- a/client/strings/sv.json +++ b/client/strings/sv.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "Rensa föremåls-cache", "ButtonPurgeMediaProgress": "Rensa medieförlopp", "ButtonQueueAddItem": "Lägg till i kön", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "Ta bort från kön", "ButtonQuickMatch": "Snabb matchning", "ButtonRead": "Läs", diff --git a/client/strings/zh-cn.json b/client/strings/zh-cn.json index 05553c081..9424a2a14 100644 --- a/client/strings/zh-cn.json +++ b/client/strings/zh-cn.json @@ -51,6 +51,7 @@ "ButtonPurgeItemsCache": "清理项目缓存", "ButtonPurgeMediaProgress": "清理媒体进度", "ButtonQueueAddItem": "添加到队列", + "ButtonQueuePlayNext": "Play Next", "ButtonQueueRemoveItem": "从队列中移除", "ButtonQuickMatch": "快速匹配", "ButtonRead": "读取",