Review changes
This commit is contained in:
@@ -294,6 +294,9 @@ export interface EventRenderOpts {
|
|||||||
disableBigEmoji?: boolean;
|
disableBigEmoji?: boolean;
|
||||||
stripReplyFallback?: boolean;
|
stripReplyFallback?: boolean;
|
||||||
forComposerQuote?: boolean;
|
forComposerQuote?: boolean;
|
||||||
|
/**
|
||||||
|
* Should inline media be rendered?
|
||||||
|
*/
|
||||||
mediaIsVisible?: boolean;
|
mediaIsVisible?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2025 New Vector Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { EventType, type MatrixEvent, type Room, RoomStateEvent, type JoinRule } from "matrix-js-sdk/src/matrix";
|
|
||||||
|
|
||||||
import { useTypedEventEmitter } from "../useEventEmitter";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to retrieve the join rules for given room
|
|
||||||
* @param room
|
|
||||||
* @returns the current join rule
|
|
||||||
*/
|
|
||||||
|
|
||||||
export function useJoinRule(room?: Room): JoinRule | undefined {
|
|
||||||
const [joinRule, setJoinRule] = useState(room?.getJoinRule());
|
|
||||||
useTypedEventEmitter(room?.currentState, RoomStateEvent.Events, (ev: MatrixEvent) => {
|
|
||||||
if (ev.getType() !== EventType.RoomJoinRules) return;
|
|
||||||
setJoinRule(room?.getJoinRule());
|
|
||||||
});
|
|
||||||
useEffect(() => {
|
|
||||||
setJoinRule(room?.getJoinRule());
|
|
||||||
}, [room]);
|
|
||||||
|
|
||||||
return joinRule;
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2025 New Vector Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
Please see LICENSE files in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { EventType, type MatrixEvent, type Room, RoomStateEvent } from "matrix-js-sdk/src/matrix";
|
|
||||||
|
|
||||||
import { useTypedEventEmitter } from "../useEventEmitter";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to retrieve the avatar for given room
|
|
||||||
* @param room
|
|
||||||
* @returns the current avatar
|
|
||||||
*/
|
|
||||||
export function useRoomAvatar(room?: Room): string | undefined {
|
|
||||||
const [avatarMxc, setAvatar] = useState(room?.getMxcAvatarUrl() ?? undefined);
|
|
||||||
useTypedEventEmitter(room?.currentState, RoomStateEvent.Events, (ev: MatrixEvent) => {
|
|
||||||
if (ev.getType() !== EventType.RoomAvatar) return;
|
|
||||||
setAvatar(room?.getMxcAvatarUrl() ?? undefined);
|
|
||||||
});
|
|
||||||
useEffect(() => {
|
|
||||||
setAvatar(room?.getMxcAvatarUrl() ?? undefined);
|
|
||||||
}, [room]);
|
|
||||||
|
|
||||||
return avatarMxc;
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ import { useSettingValue } from "./useSettings";
|
|||||||
import SettingsStore from "../settings/SettingsStore";
|
import SettingsStore from "../settings/SettingsStore";
|
||||||
import { useMatrixClientContext } from "../contexts/MatrixClientContext";
|
import { useMatrixClientContext } from "../contexts/MatrixClientContext";
|
||||||
import { MediaPreviewValue } from "../@types/media_preview";
|
import { MediaPreviewValue } from "../@types/media_preview";
|
||||||
import { useJoinRule } from "./room/useJoinRule";
|
import { useRoomState } from "./useRoomState";
|
||||||
|
|
||||||
const PRIVATE_JOIN_RULES: JoinRule[] = [JoinRule.Invite, JoinRule.Knock, JoinRule.Restricted];
|
const PRIVATE_JOIN_RULES: JoinRule[] = [JoinRule.Invite, JoinRule.Knock, JoinRule.Restricted];
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ export function useMediaVisible(eventId?: string, roomId?: string): [boolean, (v
|
|||||||
const mediaPreviewSetting = useSettingValue("mediaPreviewConfig", roomId);
|
const mediaPreviewSetting = useSettingValue("mediaPreviewConfig", roomId);
|
||||||
const client = useMatrixClientContext();
|
const client = useMatrixClientContext();
|
||||||
const eventVisibility = useSettingValue("showMediaEventIds");
|
const eventVisibility = useSettingValue("showMediaEventIds");
|
||||||
const joinRule = useJoinRule(client?.getRoom(roomId) ?? undefined);
|
const joinRule = useRoomState(client.getRoom(roomId) ?? undefined, (state) => state.getJoinRule());
|
||||||
const setMediaVisible = useCallback(
|
const setMediaVisible = useCallback(
|
||||||
(visible: boolean) => {
|
(visible: boolean) => {
|
||||||
SettingsStore.setValue("showMediaEventIds", null, SettingLevel.DEVICE, {
|
SettingsStore.setValue("showMediaEventIds", null, SettingLevel.DEVICE, {
|
||||||
|
|||||||
@@ -40,5 +40,5 @@ export default abstract class MatrixClientBackedController extends SettingContro
|
|||||||
return MatrixClientBackedController._matrixClient;
|
return MatrixClientBackedController._matrixClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected initMatrixClient?(newClient: MatrixClient, oldClient?: MatrixClient): Promise<void>;
|
protected initMatrixClient?(newClient: MatrixClient, oldClient?: MatrixClient): void;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user