From e2ca5d58195f55be07bcae7c170accbe8c251f04 Mon Sep 17 00:00:00 2001 From: Reiko Kaps Date: Sun, 15 Jun 2025 21:38:16 +0200 Subject: [PATCH] Subtitle shows now the unreads sum --- src/components/services/Miniflux.vue | 49 ++++++++++++++++++---------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/components/services/Miniflux.vue b/src/components/services/Miniflux.vue index cfce700..b4bf149 100644 --- a/src/components/services/Miniflux.vue +++ b/src/components/services/Miniflux.vue @@ -7,7 +7,7 @@ {{ item.subtitle }}

@@ -34,24 +34,39 @@ export default { }), created() { this.fetchStatus(); + this.fetchUnreads(); }, methods: { - fetchStatus: async function () { - const headers = { - 'X-Auth-Token': this.item.apikey, - }; - this.fetch("/v1/version", { headers }) - .then((response) => { - - - this.status = "online"; - this.versionstring = response.version; - }) - .catch((e) => { - this.status = "offline"; - console.log(e); - }); - }, + fetchStatus: async function () { + const headers = { + 'X-Auth-Token': this.item.apikey, + }; + this.fetch("/v1/version", { headers }) + .then((response) => { + this.status = "online"; + // this.versionstring = response.version; + }) + .catch((e) => { + this.status = "offline"; + console.log(e); + }); + }, + fetchUnreads: async function() { + const headers = { + 'X-Auth-Token': this.item.apikey, + }; + this.fetch("/v1/feeds/counters", { headers }) + .then((response) => { + this.versionstring = this.countUnreads(response.unreads); + }) + .catch((e) => { + console.log(e); + }); + }, + countUnreads: function (unreads) { + // count all values on the array + return Object.values(unreads).reduce((a, b) => a + b, 0); + }, }, };