feat: Sleep timer (fix #119)
All checks were successful
repod / xml (push) Successful in 1m25s
repod / php (push) Successful in 1m0s
repod / nodejs (push) Successful in 1m16s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-11-09 19:42:17 +01:00
parent 8cb58fe388
commit e9166ff307
11 changed files with 198 additions and 26 deletions

View File

@ -36,6 +36,10 @@ OC.L10N.register(
"Import subscriptions" : "Importiere Abonnements",
"Import OPML file" : "Importiere OPML-Datei",
"Rate RePod ❤️" : "Bewerte RePod ❤️",
"Sleep timer" : "Einschlaftimer",
"Minutes" : "Minuten",
"_%n min_::_%n mins_" : ["%n min","%n mins"],
"_%n sec_::_%n secs_" : ["%s sec","%n secs"],
"Playback speed" : "Wiedergabegeschwindigkeit",
"Favorite" : "Favorit",
"Are you sure you want to delete this subscription?" : "Bist Du sicher, dass Du das Abonnement löschen möchtest?",

View File

@ -34,6 +34,10 @@
"Import subscriptions" : "Importiere Abonnements",
"Import OPML file" : "Importiere OPML-Datei",
"Rate RePod ❤️" : "Bewerte RePod ❤️",
"Sleep timer" : "Einschlaftimer",
"Minutes" : "Minuten",
"_%n min_::_%n mins_" : ["%n min","%n mins"],
"_%n sec_::_%n secs_" : ["%s sec","%n secs"],
"Playback speed" : "Wiedergabegeschwindigkeit",
"Favorite" : "Favorit",
"Are you sure you want to delete this subscription?" : "Bist Du sicher, dass Du das Abonnement löschen möchtest?",

View File

@ -36,6 +36,10 @@ OC.L10N.register(
"Import subscriptions" : "Importer les abonnements",
"Import OPML file" : "Importer un fichier OPML",
"Rate RePod ❤️" : "Donnez votre avis ❤️",
"Sleep timer" : "Minuteur",
"Minutes" : "Minutes",
"_%n min_::_%n mins_" : ["%n min","%n mins"],
"_%n sec_::_%n secs_" : ["%s sec","%n secs"],
"Playback speed" : "Vitesse de lecture",
"Favorite" : "Favori",
"Are you sure you want to delete this subscription?" : "Êtes-vous sûr de vouloir supprimer ce flux ?",

View File

@ -34,6 +34,10 @@
"Import subscriptions" : "Importer les abonnements",
"Import OPML file" : "Importer un fichier OPML",
"Rate RePod ❤️" : "Donnez votre avis ❤️",
"Sleep timer" : "Minuteur",
"Minutes" : "Minutes",
"_%n min_::_%n mins_" : ["%n min","%n mins"],
"_%n sec_::_%n secs_" : ["%s sec","%n secs"],
"Playback speed" : "Vitesse de lecture",
"Favorite" : "Favori",
"Are you sure you want to delete this subscription?" : "Êtes-vous sûr de vouloir supprimer ce flux ?",

View File

@ -1,6 +1,5 @@
<template>
<NcAppNavigationItem
:allow-collapse="true"
menu-placement="top"
:name="t('repod', 'Filtering episodes')">
<template #actions>

View File

@ -1,6 +1,7 @@
<template>
<NcAppNavigationSettings>
<Filters />
<Sleep />
<Speed />
<Import />
<Export />
@ -14,6 +15,7 @@ import Filters from './Filters.vue'
import Import from './Import.vue'
import { NcAppNavigationSettings } from '@nextcloud/vue'
import Rate from './Rate.vue'
import Sleep from './Sleep.vue'
import Speed from './Speed.vue'
export default {
@ -24,6 +26,7 @@ export default {
Import,
NcAppNavigationSettings,
Rate,
Sleep,
Speed,
},
}

View File

@ -0,0 +1,103 @@
<template>
<NcAppNavigationItem menu-placement="top" :name="t('repod', 'Sleep timer')">
<template #actions>
<NcActionInput
v-if="!sleep"
v-model="input"
:label="t('repod', 'Minutes')"
:label-outside="false"
type="number"
@submit="setTimer">
<template #icon>
<ClockVue :size="20" />
</template>
</NcActionInput>
</template>
<template #extra>
<div v-if="sleep" class="extra">
{{ label }}
<BellCancel class="pointer" :size="20" @click="stopTimer" />
</div>
</template>
<template #icon>
<BellSleepIcon v-if="sleep" :size="20" />
<BellSleepOutlineIcon v-if="!sleep" :size="20" />
</template>
</NcAppNavigationItem>
</template>
<script lang="ts">
import { NcActionInput, NcAppNavigationItem } from '@nextcloud/vue'
import { n, t } from '@nextcloud/l10n'
import BellCancel from 'vue-material-design-icons/BellCancel.vue'
import BellSleepIcon from 'vue-material-design-icons/BellSleep.vue'
import BellSleepOutlineIcon from 'vue-material-design-icons/BellSleepOutline.vue'
import ClockVue from 'vue-material-design-icons/Clock.vue'
import { mapActions } from 'pinia'
import { usePlayer } from '../../store/player.ts'
export default {
name: 'Sleep',
components: {
BellCancel,
BellSleepIcon,
BellSleepOutlineIcon,
ClockVue,
NcActionInput,
NcAppNavigationItem,
},
data: () => ({
input: 10,
sleep: null as NodeJS.Timeout | null,
timer: 0,
}),
computed: {
label() {
if (this.timer > 60) {
return this.n(
'repod',
'%n min',
'%n mins',
Math.round(this.timer / 60),
)
} else {
return this.n('repod', '%n sec', '%n secs', this.timer)
}
},
},
methods: {
...mapActions(usePlayer, ['stop']),
n,
t,
setTimer() {
this.timer = this.input * 60
this.sleep = setInterval(() => {
if (this.timer > 0) {
this.timer--
} else if (this.sleep) {
this.stopTimer()
this.stop()
}
}, 1000)
},
stopTimer() {
if (this.sleep) {
clearTimeout(this.sleep)
this.sleep = null
}
},
},
}
</script>
<style scoped>
.extra {
align-items: center;
display: flex;
gap: 0.5rem;
}
.pointer {
cursor: pointer;
}
</style>

View File

@ -71,12 +71,10 @@ export default {
required: true,
},
},
data() {
return {
data: () => ({
failed: false,
loading: true,
}
},
}),
computed: {
...mapState(useSubscriptions, ['getSubByUrl', 'subs']),
feed() {

View File

@ -145,6 +145,22 @@ msgstr "Importiere OPML-Datei"
msgid "Rate RePod ❤️"
msgstr "Bewerte RePod ❤️"
msgid "Sleep timer"
msgstr "Einschlaftimer"
msgid "Minutes"
msgstr "Minuten"
msgid "%n min"
msgid_plural "%n mins"
msgstr[0] "%n min"
msgstr[1] "%n mins"
msgid "%n sec"
msgid_plural "%n secs"
msgstr[0] "%s sec"
msgstr[1] "%n secs"
msgid "Playback speed"
msgstr "Wiedergabegeschwindigkeit"

View File

@ -149,6 +149,22 @@ msgstr "Importer un fichier OPML"
msgid "Rate RePod ❤️"
msgstr "Donnez votre avis ❤️"
msgid "Sleep timer"
msgstr "Minuteur"
msgid "Minutes"
msgstr "Minutes"
msgid "%n min"
msgid_plural "%n mins"
msgstr[0] "%n min"
msgstr[1] "%n mins"
msgid "%n sec"
msgid_plural "%n secs"
msgstr[0] "%s sec"
msgstr[1] "%n secs"
msgid "Playback speed"
msgstr "Vitesse de lecture"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Nextcloud 3.14159\n"
"Report-Msgid-Bugs-To: translations\\@example.com\n"
"POT-Creation-Date: 2024-11-08 23:27+0000\n"
"POT-Creation-Date: 2024-11-09 18:34+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -16,6 +16,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: /app/lib/Controller/OpmlController.php:46
msgid "RePod Subscriptions"
@ -189,56 +190,76 @@ msgid "Rate RePod ❤️"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:46
msgid "Playback speed"
msgid "Sleep timer"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:47
#: /app/specialVueFakeDummyForL10nScript.js:48
#: /app/specialVueFakeDummyForL10nScript.js:49
msgid "Favorite"
msgid "Minutes"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:48
msgid "%n min"
msgid_plural "%n mins"
msgstr[0] ""
msgstr[1] ""
#: /app/specialVueFakeDummyForL10nScript.js:49
msgid "%n sec"
msgid_plural "%n secs"
msgstr[0] ""
msgstr[1] ""
#: /app/specialVueFakeDummyForL10nScript.js:50
msgid "Are you sure you want to delete this subscription?"
msgid "Playback speed"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:51
msgid "Error while removing the feed"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:52
msgid "You can only have 10 favorites"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:53
msgid "Add a podcast"
msgid "Favorite"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:54
msgid "Could not fetch subscriptions"
msgid "Are you sure you want to delete this subscription?"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:55
msgid "Find a podcast"
msgid "Error while removing the feed"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:56
msgid "Error loading feed"
msgid "You can only have 10 favorites"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:57
msgid "Missing required app"
msgid "Add a podcast"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:58
msgid "Install GPodder Sync"
msgid "Could not fetch subscriptions"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:59
msgid "Pin some subscriptions to see their latest updates"
msgid "Find a podcast"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:60
msgid "Error loading feed"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:61
msgid "Missing required app"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:62
msgid "Install GPodder Sync"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:63
msgid "Pin some subscriptions to see their latest updates"
msgstr ""
#: /app/specialVueFakeDummyForL10nScript.js:64
msgid "No favorites"
msgstr ""