From 86df4993e1a673a72bd686aa2270a09d5c381c81 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 24 Sep 2020 16:45:28 +0200 Subject: [PATCH] prevent room summary from being updated every time it is in /sync resp --- src/matrix/room/RoomSummary.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/matrix/room/RoomSummary.js b/src/matrix/room/RoomSummary.js index 292e7917..81a68b8f 100644 --- a/src/matrix/room/RoomSummary.js +++ b/src/matrix/room/RoomSummary.js @@ -58,9 +58,16 @@ function applySyncResponse(data, roomResponse, membership) { } const unreadNotifications = roomResponse.unread_notifications; if (unreadNotifications) { - data = data.cloneIfNeeded(); - data.highlightCount = unreadNotifications.highlight_count || 0; - data.notificationCount = unreadNotifications.notification_count; + const highlightCount = unreadNotifications.highlight_count || 0; + if (highlightCount !== data.highlightCount) { + data = data.cloneIfNeeded(); + data.highlightCount = highlightCount; + } + const notificationCount = unreadNotifications.notification_count; + if (notificationCount !== data.notificationCount) { + data = data.cloneIfNeeded(); + data.notificationCount = notificationCount; + } } return data;