RoomListStore: Unread filter should match rooms that were marked as unread (#29580)
* Unread filter should match rooms marked as unread * Re-insert room into skip list on account data So that filters are re-calculated when rooms are marked as unread. * Write test
This commit is contained in:
@@ -33,6 +33,7 @@ import { MentionsFilter } from "./skip-list/filters/MentionsFilter";
|
||||
import { LowPriorityFilter } from "./skip-list/filters/LowPriorityFilter";
|
||||
import { type Sorter, SortingAlgorithm } from "./skip-list/sorters";
|
||||
import { SettingLevel } from "../../settings/SettingLevel";
|
||||
import { MARKED_UNREAD_TYPE_STABLE, MARKED_UNREAD_TYPE_UNSTABLE } from "../../utils/notifications";
|
||||
|
||||
/**
|
||||
* These are the filters passed to the room skip list.
|
||||
@@ -156,6 +157,15 @@ export class RoomListStoreV3Class extends AsyncStoreWithClient<EmptyObject> {
|
||||
break;
|
||||
}
|
||||
|
||||
case "MatrixActions.Room.accountData": {
|
||||
const eventType = payload.event_type;
|
||||
if (eventType === MARKED_UNREAD_TYPE_STABLE || eventType === MARKED_UNREAD_TYPE_UNSTABLE) {
|
||||
const room = payload.room;
|
||||
this.addRoomAndEmit(room);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "MatrixActions.Event.decrypted": {
|
||||
const roomId = payload.event.getRoomId();
|
||||
if (!roomId) return;
|
||||
|
||||
@@ -8,10 +8,11 @@ import type { Room } from "matrix-js-sdk/src/matrix";
|
||||
import type { Filter } from ".";
|
||||
import { FilterKey } from ".";
|
||||
import { RoomNotificationStateStore } from "../../../notifications/RoomNotificationStateStore";
|
||||
import { getMarkedUnreadState } from "../../../../utils/notifications";
|
||||
|
||||
export class UnreadFilter implements Filter {
|
||||
public matches(room: Room): boolean {
|
||||
return RoomNotificationStateStore.instance.getRoomState(room).hasUnreadCount;
|
||||
return RoomNotificationStateStore.instance.getRoomState(room).hasUnreadCount || !!getMarkedUnreadState(room);
|
||||
}
|
||||
|
||||
public get key(): FilterKey.UnreadFilter {
|
||||
|
||||
Reference in New Issue
Block a user