Subtitle shows now the unreads sum

pull/944/head
Reiko Kaps 2025-06-15 21:38:16 +02:00
parent 89ec89cb2f
commit e2ca5d5819
1 changed files with 32 additions and 17 deletions

View File

@ -7,7 +7,7 @@
{{ item.subtitle }} {{ item.subtitle }}
</template> </template>
<template v-else-if="versionstring"> <template v-else-if="versionstring">
Version {{ versionstring }} Unreads {{ versionstring }}
</template> </template>
</p> </p>
</template> </template>
@ -34,24 +34,39 @@ export default {
}), }),
created() { created() {
this.fetchStatus(); this.fetchStatus();
this.fetchUnreads();
}, },
methods: { methods: {
fetchStatus: async function () { fetchStatus: async function () {
const headers = { const headers = {
'X-Auth-Token': this.item.apikey, 'X-Auth-Token': this.item.apikey,
}; };
this.fetch("/v1/version", { headers }) this.fetch("/v1/version", { headers })
.then((response) => { .then((response) => {
this.status = "online";
// this.versionstring = response.version;
this.status = "online"; })
this.versionstring = response.version; .catch((e) => {
}) this.status = "offline";
.catch((e) => { console.log(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);
},
}, },
}; };
</script> </script>