forked from mystiq/hydrogen-web
extract fn
This commit is contained in:
parent
b13bfee3d8
commit
2cfe7034e8
1 changed files with 15 additions and 10 deletions
|
@ -68,21 +68,26 @@ function applySyncResponse(data, roomResponse, membership, ownUserId) {
|
||||||
}
|
}
|
||||||
const unreadNotifications = roomResponse.unread_notifications;
|
const unreadNotifications = roomResponse.unread_notifications;
|
||||||
if (unreadNotifications) {
|
if (unreadNotifications) {
|
||||||
const highlightCount = unreadNotifications.highlight_count || 0;
|
data = processNotificationCounts(data, unreadNotifications);
|
||||||
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;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processNotificationCounts(data, unreadNotifications) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
function processRoomAccountData(data, event) {
|
function processRoomAccountData(data, event) {
|
||||||
if (event?.type === "m.tag") {
|
if (event?.type === "m.tag") {
|
||||||
let tags = event?.content?.tags;
|
let tags = event?.content?.tags;
|
||||||
|
|
Loading…
Reference in a new issue