diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index c508220f..8bf6a132 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -29,7 +29,7 @@ import { LobbyView } from "./LobbyView"; import { InCallView } from "./InCallView"; import { PTTCallView } from "./PTTCallView"; import { CallEndedView } from "./CallEndedView"; -import { useRoomAvatar } from "./useRoomState"; +import { useRoomAvatar } from "./useRoomAvatar"; import { useSentryGroupCallHandler } from "./useSentryGroupCallHandler"; import { useLocationNavigation } from "../useLocationNavigation"; import { useMediaHandler } from "../settings/useMediaHandler"; diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 86cb29cb..e6272ca3 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -58,7 +58,7 @@ import { useFullscreen } from "../video-grid/useFullscreen"; import { AudioContainer } from "../video-grid/AudioContainer"; import { useAudioOutputDevice } from "../video-grid/useAudioOutputDevice"; import { widget, ElementWidgetActions } from "../widget"; -import { useJoinRule } from "./useRoomState"; +import { useJoinRule } from "./useJoinRule"; const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); // There is currently a bug in Safari our our code with cloning and sending MediaStreams diff --git a/src/room/useJoinRule.ts b/src/room/useJoinRule.ts new file mode 100644 index 00000000..78abc507 --- /dev/null +++ b/src/room/useJoinRule.ts @@ -0,0 +1,26 @@ +/* +Copyright 2022 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { useCallback } from "react"; + +import type { Room } from "matrix-js-sdk/src/models/room"; +import { useRoomState } from "./useRoomState"; + +export const useJoinRule = (room: Room) => + useRoomState( + room, + useCallback((state) => state.getJoinRule(), []) + ); diff --git a/src/room/useRoomAvatar.ts b/src/room/useRoomAvatar.ts new file mode 100644 index 00000000..4c4d0152 --- /dev/null +++ b/src/room/useRoomAvatar.ts @@ -0,0 +1,26 @@ +/* +Copyright 2022 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { useCallback } from "react"; +import { Room } from "matrix-js-sdk/src/models/room"; + +import { useRoomState } from "./useRoomState"; + +export const useRoomAvatar = (room: Room) => + useRoomState( + room, + useCallback(() => room.getMxcAvatarUrl(), [room]) + ); diff --git a/src/room/useRoomState.ts b/src/room/useRoomState.ts index 5f237947..2fa4d0b7 100644 --- a/src/room/useRoomState.ts +++ b/src/room/useRoomState.ts @@ -37,15 +37,3 @@ export const useRoomState = (room: Room, f: (state: RoomState) => T): T => { // eslint-disable-next-line react-hooks/exhaustive-deps return useMemo(() => f(room.currentState), [room, f, numUpdates]); }; - -export const useRoomAvatar = (room: Room) => - useRoomState( - room, - useCallback(() => room.getMxcAvatarUrl(), [room]) - ); - -export const useJoinRule = (room: Room) => - useRoomState( - room, - useCallback((state) => state.getJoinRule(), []) - );