refactor: listen to RoomEvent.Tags instead of relying on the old room list store to update the summary card (#32728)

This commit is contained in:
Florian Duros 2026-03-05 11:35:59 +01:00 committed by GitHub
parent 83d732d60e
commit 9035da48a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,14 @@ Please see LICENSE files in the repository root for full details.
*/
import { useEffect, useRef, useState } from "react";
import { EventType, type HistoryVisibility, type JoinRule, type Room, RoomStateEvent } from "matrix-js-sdk/src/matrix";
import {
EventType,
type HistoryVisibility,
type JoinRule,
type Room,
RoomEvent,
RoomStateEvent,
} from "matrix-js-sdk/src/matrix";
import { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
import { useIsEncrypted } from "../../../hooks/useIsEncrypted";
@ -17,7 +24,6 @@ import { useAccountData } from "../../../hooks/useAccountData";
import { useDispatcher } from "../../../hooks/useDispatcher";
import defaultDispatcher from "../../../dispatcher/dispatcher";
import { Action } from "../../../dispatcher/actions";
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
import { canInviteTo } from "../../../utils/room/canInviteTo";
import { DefaultTagID } from "../../../stores/room-list-v3/skip-list/tag";
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
@ -172,7 +178,7 @@ export function useRoomSummaryCardViewModel(
// value to check if the user can invite to the room
const canInviteToState = useEventEmitterState(room, RoomStateEvent.Update, () => canInviteTo(room));
const roomTags = useEventEmitterState(RoomListStore.instance, LISTS_UPDATE_EVENT, () => getTagsForRoom(room));
const roomTags = useEventEmitterState(room, RoomEvent.Tags, () => getTagsForRoom(room));
const isFavorite = roomTags.includes(DefaultTagID.Favourite);
const isDirectMessage = useIsDirectMessage(room);