New room list: fix incorrect decoration (#29770)
* fix(call): reset call value when the roomId changes * fix(call): reset presence indicator when the room changes * refactor: use existing `usePresence` * test: fix room avatar view test * test: update snapshots
This commit is contained in:
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
import { useState, useCallback, useMemo, useEffect } from "react";
|
||||
|
||||
import type { RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import { type Call, ConnectionState, CallEvent } from "../models/Call";
|
||||
@@ -20,6 +20,12 @@ export const useCall = (roomId: string): Call | null => {
|
||||
useEventEmitter(CallStore.instance, CallStoreEvent.Call, (call: Call | null, forRoomId: string) => {
|
||||
if (forRoomId === roomId) setCall(call);
|
||||
});
|
||||
|
||||
// Reset the value when the roomId changes
|
||||
useEffect(() => {
|
||||
setCall(CallStore.instance.getCall(roomId));
|
||||
}, [roomId]);
|
||||
|
||||
return call;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user