From 47c72d00292f73d5ab784edceebd2a0239b31c87 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Tue, 16 Mar 2021 21:45:27 +0000 Subject: [PATCH] Replace items with unread on background sync --- views/index.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/views/index.html b/views/index.html index 93a8206..1074c7d 100644 --- a/views/index.html +++ b/views/index.html @@ -418,12 +418,21 @@ fetch(`/api/unread`) .then(res => res.json()) .then(items => { - for (let item of items) { - if (!this.items.some(i => i.ID == item.ID)) { - this.items.unshift(item); - this.setPageTitle(); + if (!this.showRead) { + if (!items.some(i => i.ID == this.selectedItem)) { + items.unshift(this.items.find(i => i.ID == this.selectedItem)); + } + + this.items = items; + } else { + for (let item of items) { + if (!this.items.some(i => i.ID == item.ID)) { + this.items.unshift(item); + } } } + + this.setPageTitle(); }) }, 5 * 60 * 1000);