Fix wrong notification count

This commit is contained in:
Ajay Bura 2022-09-04 08:58:24 +05:30
parent e25fd8a577
commit 392bd158ce
2 changed files with 7 additions and 9 deletions

View file

@ -168,7 +168,7 @@ function Search() {
}
};
const notifs = initMatrix.notifications;
const noti = initMatrix.notifications;
const renderRoomSelector = (item) => {
let imageSrc = null;
let iconSrc = null;
@ -178,9 +178,6 @@ function Search() {
iconSrc = joinRuleToIconSrc(item.room.getJoinRule(), item.type === 'space');
}
const isUnread = notifs.hasNoti(item.roomId);
const noti = notifs.getNoti(item.roomId);
return (
<RoomSelector
key={item.roomId}
@ -189,9 +186,9 @@ function Search() {
roomId={item.roomId}
imageSrc={imageSrc}
iconSrc={iconSrc}
isUnread={isUnread}
notificationCount={noti.total}
isAlert={noti.highlight > 0}
isUnread={noti.hasNoti(item.roomId)}
notificationCount={noti.getTotalNoti(item.roomId)}
isAlert={noti.getHighlightNoti(item.roomId) > 0}
onClick={() => openItem(item.roomId, item.type)}
/>
);
@ -207,7 +204,7 @@ function Search() {
size="small"
>
<div className="search-dialog">
<form className="search-dialog__input" onSubmit={(e) => { e.preventDefault(); openFirstResult()}}>
<form className="search-dialog__input" onSubmit={(e) => { e.preventDefault(); openFirstResult(); }}>
<RawIcon src={SearchIC} size="small" />
<Input
onChange={handleOnChange}

View file

@ -104,7 +104,8 @@ class Notifications extends EventEmitter {
}
getTotalNoti(roomId) {
const { total } = this.getNoti(roomId);
const { total, highlight } = this.getNoti(roomId);
if (highlight > total) return highlight;
return total;
}