summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/service-worker.js15
1 files changed, 1 insertions, 14 deletions
diff --git a/ui/service-worker.js b/ui/service-worker.js
index 3a54d1e..391705c 100644
--- a/ui/service-worker.js
+++ b/ui/service-worker.js
@@ -18,12 +18,9 @@ const conversationReadStatus = {
};
function countUnreadChannels() {
- console.debug(conversationReadStatus);
return Object.entries(conversationReadStatus)
.map(([conversationId, { lastRead, lastMessage }]) => {
- const unread = (!lastRead || (lastRead < lastMessage)) ? 1 : 0;
- if (unread) { console.debug(`Found unread in ${conversationId}`, lastRead, lastMessage); }
- return unread;
+ return !lastRead || lastRead < lastMessage ? 1 : 0;
})
.reduce((total, current) => total + current, 0);
}
@@ -42,10 +39,6 @@ self.addEventListener('push', (event) => {
// Now we can do slower things that might fail:
conversationReadStatus[data.conversation] ||= { lastRead: null, lastMessage: null };
conversationReadStatus[data.conversation].lastMessage = new Date();
- console.debug(
- `Last message in ${data.conversation}`,
- conversationReadStatus[data.conversation].lastMessage,
- );
event.waitUntil(
(async () => {
if (navigator.setAppBadge) {
@@ -62,16 +55,10 @@ self.addEventListener('message', (event) => {
case 'CONVERSATION_READ':
conversationReadStatus[data.conversationId] ||= { lastRead: null, lastMessage: null };
if (data.at) {
- console.debug('Found data.at', new Date(data.at.ts));
conversationReadStatus[data.conversationId].lastRead = new Date(data.at.ts);
} else {
- console.debug('Found no data.at');
conversationReadStatus[data.conversationId].lastRead = new Date();
}
- console.debug(
- `Last read in ${data.conversationId}`,
- conversationReadStatus[data.conversationId].lastRead,
- );
event.waitUntil(
(async () => {
if (navigator.setAppBadge) {