Fix wrong notification count

This commit is contained in:
Ajay Bura 2022-09-06 14:22:56 +05:30
parent e1adc6a3bc
commit 790bf5eac3
2 changed files with 7 additions and 8 deletions

View file

@ -21,7 +21,7 @@ import ChevronRightIC from '../../../../public/res/ic/outlined/chevron-right.svg
function DrawerBreadcrumb({ spaceId }) { function DrawerBreadcrumb({ spaceId }) {
const [, forceUpdate] = useState({}); const [, forceUpdate] = useState({});
const scrollRef = useRef(null); const scrollRef = useRef(null);
const { roomList, notifications } = initMatrix; const { roomList, notifications, accountData } = initMatrix;
const mx = initMatrix.matrixClient; const mx = initMatrix.matrixClient;
const spacePath = navigation.selectedSpacePath; const spacePath = navigation.selectedSpacePath;
@ -49,9 +49,9 @@ function DrawerBreadcrumb({ spaceId }) {
}, [spaceId]); }, [spaceId]);
function getHomeNotiExcept(childId) { function getHomeNotiExcept(childId) {
const orphans = roomList.getOrphans(); const orphans = roomList.getOrphans()
const childIndex = orphans.indexOf(childId); .filter((id) => (id !== childId))
if (childId !== -1) orphans.splice(childIndex, 1); .filter((id) => !accountData.spaceShortcut.has(id));
let noti = null; let noti = null;

View file

@ -114,8 +114,7 @@ class Notifications extends EventEmitter {
} }
getTotalNoti(roomId) { getTotalNoti(roomId) {
const { total, highlight } = this.getNoti(roomId); const { total } = this.getNoti(roomId);
if (highlight > total) return highlight;
return total; return total;
} }
@ -166,7 +165,7 @@ class Notifications extends EventEmitter {
_setNoti(roomId, total, highlight) { _setNoti(roomId, total, highlight) {
const addNoti = (id, t, h, fromId) => { const addNoti = (id, t, h, fromId) => {
const prevTotal = this.roomIdToNoti.get(id)?.total ?? null; const prevTotal = this.roomIdToNoti.has(id) ? this.getT : null;
const noti = this.getNoti(id); const noti = this.getNoti(id);
noti.total += t; noti.total += t;
@ -181,7 +180,7 @@ class Notifications extends EventEmitter {
}; };
const noti = this.getNoti(roomId); const noti = this.getNoti(roomId);
const addT = total - noti.total; const addT = (highlight > total ? highlight : total) - noti.total;
const addH = highlight - noti.highlight; const addH = highlight - noti.highlight;
if (addT < 0 || addH < 0) return; if (addT < 0 || addH < 0) return;