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:
@@ -5,7 +5,14 @@ Please see LICENSE files in the repository root for full details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
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 { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
|
||||||
import { useIsEncrypted } from "../../../hooks/useIsEncrypted";
|
import { useIsEncrypted } from "../../../hooks/useIsEncrypted";
|
||||||
@@ -17,7 +24,6 @@ import { useAccountData } from "../../../hooks/useAccountData";
|
|||||||
import { useDispatcher } from "../../../hooks/useDispatcher";
|
import { useDispatcher } from "../../../hooks/useDispatcher";
|
||||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||||
import { Action } from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
|
|
||||||
import { canInviteTo } from "../../../utils/room/canInviteTo";
|
import { canInviteTo } from "../../../utils/room/canInviteTo";
|
||||||
import { DefaultTagID } from "../../../stores/room-list-v3/skip-list/tag";
|
import { DefaultTagID } from "../../../stores/room-list-v3/skip-list/tag";
|
||||||
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
||||||
@@ -172,7 +178,7 @@ export function useRoomSummaryCardViewModel(
|
|||||||
// value to check if the user can invite to the room
|
// value to check if the user can invite to the room
|
||||||
const canInviteToState = useEventEmitterState(room, RoomStateEvent.Update, () => canInviteTo(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 isFavorite = roomTags.includes(DefaultTagID.Favourite);
|
||||||
|
|
||||||
const isDirectMessage = useIsDirectMessage(room);
|
const isDirectMessage = useIsDirectMessage(room);
|
||||||
|
|||||||
Reference in New Issue
Block a user