fix: correct isNotificationEvent function usage

- Update BackgroundNotifications.tsx to use single-argument isNotificationEvent
- Update roomToUnread.ts to use single-argument isNotificationEvent
- Auto-format files with prettier
- All TypeScript and ESLint checks passing
This commit is contained in:
Evie Gauthier committed 2026-03-12 14:53:44 -04:00
1 parent bd31de7b54
commit 1d12be5f31
3 files changed
+9 -8

No files matched your search

@@ -297,8 +297,7 @@ export function BackgroundNotifications() {
return;
}
const userId = mx.getUserId();
if (!isNotificationEvent(mEvent, room, userId)) {
if (!isNotificationEvent(mEvent)) {
return;
}
+1 -1
View File
@@ -230,7 +230,7 @@ export const useBindRoomToUnreadAtom = (mx: MatrixClient, unreadAtom: typeof roo
}
// Handle live events (new messages arriving in real-time)
if (data.liveEvent && isNotificationEvent(mEvent, room, mx.getUserId())) {
if (data.liveEvent && isNotificationEvent(mEvent)) {
if (mEvent.getSender() === mx.getUserId()) return;
const unreadInfo = getUnreadInfo(room, { applyFixup: shouldApplyUnreadFixup(), mDirects });
setUnreadAtom({
+7 -5
View File
@@ -224,10 +224,10 @@ export const isNotificationEvent = (mEvent: MatrixEvent, room?: Room, userId?: s
if (mEvent.isRedacted()) return false;
const relation = mEvent.getRelation();
const relationType = relation?.rel_type;
// Filter out edits - they shouldn't count as new notifications
if (relationType === 'm.replace') return false;
// For reactions: only count them if they're reactions to the current user's messages
if (relationType === 'm.annotation') {
if (!room || !userId || !relation) {
@@ -237,12 +237,12 @@ export const isNotificationEvent = (mEvent: MatrixEvent, room?: Room, userId?: s
// Get the event being reacted to
const reactedToEventId = relation.event_id;
if (!reactedToEventId) return false;
const reactedToEvent = room.findEventById(reactedToEventId);
// Only count as notification if the reacted-to message was sent by current user
return reactedToEvent?.getSender() === userId;
}
return true;
};
@@ -319,7 +319,9 @@ export const getUnreadInfo = (room: Room, options?: UnreadInfoOptions): UnreadIn
.reverse()
.find(
(event) =>
!event.isSending() && event.getSender() !== userId && isNotificationEvent(event, room, userId)
!event.isSending() &&
event.getSender() !== userId &&
isNotificationEvent(event, room, userId)
);
const latestNotificationId = latestNotification?.getId();
if (latestNotificationId && room.hasUserReadEvent(userId, latestNotificationId)) {