Enable @typescript-eslint/explicit-function-return-type
in /src (#9788)
* Enable `@typescript-eslint/explicit-member-accessibility` on /src * Prettier * Enable `@typescript-eslint/explicit-function-return-type` in /src * Fix types * tsc strict fixes * Delint * Fix test * Fix bad merge
This commit is contained in:
parent
7a36ba0fde
commit
030b7e90bf
683 changed files with 3459 additions and 3013 deletions
|
@ -57,7 +57,7 @@ const BaseCard: React.FC<IProps> = forwardRef<HTMLDivElement, IProps>(
|
|||
const cardHistory = RightPanelStore.instance.roomPhaseHistory;
|
||||
if (cardHistory.length > 1) {
|
||||
const prevCard = cardHistory[cardHistory.length - 2];
|
||||
const onBackClick = (ev: ButtonEvent) => {
|
||||
const onBackClick = (ev: ButtonEvent): void => {
|
||||
onBack?.(ev);
|
||||
RightPanelStore.instance.popCard();
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ import { _t } from "../../../languageHandler";
|
|||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import Spinner from "../elements/Spinner";
|
||||
|
||||
export const PendingActionSpinner = ({ text }) => {
|
||||
export const PendingActionSpinner: React.FC<{ text: string }> = ({ text }) => {
|
||||
return (
|
||||
<div className="mx_EncryptionInfo_spinner">
|
||||
<Spinner />
|
||||
|
|
|
@ -63,7 +63,7 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
|
|||
}, [verificationRequest]);
|
||||
|
||||
useEffect(() => {
|
||||
async function awaitPromise() {
|
||||
async function awaitPromise(): Promise<void> {
|
||||
setRequesting(true);
|
||||
const requestFromPromise = await verificationRequestPromise;
|
||||
setRequesting(false);
|
||||
|
@ -103,7 +103,7 @@ const EncryptionPanel: React.FC<IProps> = (props: IProps) => {
|
|||
|
||||
useTypedEventEmitter(request, VerificationRequestEvent.Change, changeHandler);
|
||||
|
||||
const onStartVerification = useCallback(async () => {
|
||||
const onStartVerification = useCallback(async (): Promise<void> => {
|
||||
setRequesting(true);
|
||||
const cli = MatrixClientPeg.get();
|
||||
let verificationRequest_: VerificationRequest;
|
||||
|
|
|
@ -40,7 +40,7 @@ interface IProps {
|
|||
|
||||
// TODO: replace this, the composer buttons and the right panel buttons with a unified representation
|
||||
export default class HeaderButton extends React.Component<IProps> {
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const { isHighlighted, isUnread = false, onClick, name, title, ...props } = this.props;
|
||||
|
||||
const classes = classNames({
|
||||
|
|
|
@ -56,12 +56,12 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
|||
};
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
RightPanelStore.instance.on(UPDATE_EVENT, this.onRightPanelStoreUpdate);
|
||||
this.dispatcherRef = dis.register(this.onAction.bind(this)); // used by subclasses
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
this.unmounted = true;
|
||||
RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate);
|
||||
if (this.dispatcherRef) dis.unregister(this.dispatcherRef);
|
||||
|
@ -69,7 +69,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
|||
|
||||
protected abstract onAction(payload);
|
||||
|
||||
public setPhase(phase: RightPanelPhases, cardState?: Partial<IRightPanelCardState>) {
|
||||
public setPhase(phase: RightPanelPhases, cardState?: Partial<IRightPanelCardState>): void {
|
||||
const rps = RightPanelStore.instance;
|
||||
if (rps.currentCard.phase == phase && !cardState && rps.isOpen) {
|
||||
rps.togglePanel(null);
|
||||
|
@ -88,7 +88,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
|||
}
|
||||
}
|
||||
|
||||
private onRightPanelStoreUpdate = () => {
|
||||
private onRightPanelStoreUpdate = (): void => {
|
||||
if (this.unmounted) return;
|
||||
this.setState({ phase: RightPanelStore.instance.currentCard.phase });
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
|||
// XXX: Make renderButtons a prop
|
||||
public abstract renderButtons(): JSX.Element;
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<div className="mx_HeaderButtons" role="tablist">
|
||||
{this.renderButtons()}
|
||||
|
|
|
@ -91,7 +91,7 @@ export const useReadPinnedEvents = (room: Room): Set<string> => {
|
|||
return readPinnedEvents;
|
||||
};
|
||||
|
||||
const PinnedMessagesCard = ({ room, onClose, permalinkCreator }: IProps) => {
|
||||
const PinnedMessagesCard: React.FC<IProps> = ({ room, onClose, permalinkCreator }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const roomContext = useContext(RoomContext);
|
||||
const canUnpin = useRoomState(room, (state) => state.mayClientSendStateEvent(EventType.RoomPinnedEvents, cli));
|
||||
|
@ -110,7 +110,7 @@ const PinnedMessagesCard = ({ room, onClose, permalinkCreator }: IProps) => {
|
|||
|
||||
const pinnedEvents = useAsyncMemo(
|
||||
() => {
|
||||
const promises = pinnedEventIds.map(async (eventId) => {
|
||||
const promises = pinnedEventIds.map(async (eventId): Promise<MatrixEvent | null> => {
|
||||
const timelineSet = room.getUnfilteredTimelineSet();
|
||||
const localEvent = timelineSet
|
||||
?.getTimelineForEvent(eventId)
|
||||
|
@ -159,7 +159,7 @@ const PinnedMessagesCard = ({ room, onClose, permalinkCreator }: IProps) => {
|
|||
if (!pinnedEvents) {
|
||||
content = <Spinner />;
|
||||
} else if (pinnedEvents.length > 0) {
|
||||
const onUnpinClicked = async (event: MatrixEvent) => {
|
||||
const onUnpinClicked = async (event: MatrixEvent): Promise<void> => {
|
||||
const pinnedEvents = room.currentState.getStateEvents(EventType.RoomPinnedEvents, "");
|
||||
if (pinnedEvents?.getContent()?.pinned) {
|
||||
const pinned = pinnedEvents.getContent().pinned;
|
||||
|
|
|
@ -61,7 +61,7 @@ interface IUnreadIndicatorProps {
|
|||
color?: NotificationColor;
|
||||
}
|
||||
|
||||
const UnreadIndicator = ({ color }: IUnreadIndicatorProps) => {
|
||||
const UnreadIndicator: React.FC<IUnreadIndicatorProps> = ({ color }) => {
|
||||
if (color === NotificationColor.None) {
|
||||
return null;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ interface IHeaderButtonProps {
|
|||
onClick: () => void;
|
||||
}
|
||||
|
||||
const PinnedMessagesHeaderButton = ({ room, isHighlighted, onClick }: IHeaderButtonProps) => {
|
||||
const PinnedMessagesHeaderButton: React.FC<IHeaderButtonProps> = ({ room, isHighlighted, onClick }) => {
|
||||
const pinnedEvents = usePinnedEvents(room);
|
||||
const readPinnedEvents = useReadPinnedEvents(room);
|
||||
if (!pinnedEvents?.length) return null;
|
||||
|
@ -110,7 +110,7 @@ const PinnedMessagesHeaderButton = ({ room, isHighlighted, onClick }: IHeaderBut
|
|||
);
|
||||
};
|
||||
|
||||
const TimelineCardHeaderButton = ({ room, isHighlighted, onClick }: IHeaderButtonProps) => {
|
||||
const TimelineCardHeaderButton: React.FC<IHeaderButtonProps> = ({ room, isHighlighted, onClick }) => {
|
||||
let unreadIndicator;
|
||||
const color = RoomNotificationStateStore.instance.getRoomState(room).color;
|
||||
switch (color) {
|
||||
|
@ -231,7 +231,7 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
});
|
||||
};
|
||||
|
||||
protected onAction(payload: ActionPayload) {
|
||||
protected onAction(payload: ActionPayload): void {
|
||||
if (payload.action === Action.ViewUser) {
|
||||
if (payload.member) {
|
||||
if (payload.push) {
|
||||
|
@ -258,7 +258,7 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
}
|
||||
}
|
||||
|
||||
private onRoomSummaryClicked = () => {
|
||||
private onRoomSummaryClicked = (): void => {
|
||||
// use roomPanelPhase rather than this.state.phase as it remembers the latest one if we close
|
||||
const currentPhase = RightPanelStore.instance.currentCard.phase;
|
||||
if (ROOM_INFO_PHASES.includes(currentPhase)) {
|
||||
|
@ -273,20 +273,20 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
}
|
||||
};
|
||||
|
||||
private onNotificationsClicked = () => {
|
||||
private onNotificationsClicked = (): void => {
|
||||
// This toggles for us, if needed
|
||||
this.setPhase(RightPanelPhases.NotificationPanel);
|
||||
};
|
||||
|
||||
private onPinnedMessagesClicked = () => {
|
||||
private onPinnedMessagesClicked = (): void => {
|
||||
// This toggles for us, if needed
|
||||
this.setPhase(RightPanelPhases.PinnedMessages);
|
||||
};
|
||||
private onTimelineCardClicked = () => {
|
||||
private onTimelineCardClicked = (): void => {
|
||||
this.setPhase(RightPanelPhases.Timeline);
|
||||
};
|
||||
|
||||
private onThreadsPanelClicked = (ev: ButtonEvent) => {
|
||||
private onThreadsPanelClicked = (ev: ButtonEvent): void => {
|
||||
if (RoomHeaderButtons.THREAD_PHASES.includes(this.state.phase)) {
|
||||
RightPanelStore.instance.togglePanel(this.props.room?.roomId ?? null);
|
||||
} else {
|
||||
|
@ -295,7 +295,7 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
}
|
||||
};
|
||||
|
||||
public renderButtons() {
|
||||
public renderButtons(): JSX.Element {
|
||||
if (!this.props.room) {
|
||||
return <></>;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ const Button: React.FC<IButtonProps> = ({ children, className, onClick }) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const useWidgets = (room: Room) => {
|
||||
export const useWidgets = (room: Room): IApp[] => {
|
||||
const [apps, setApps] = useState<IApp[]>(() => WidgetStore.instance.getApps(room.roomId));
|
||||
|
||||
const updateApps = useCallback(() => {
|
||||
|
@ -107,7 +107,7 @@ const AppRow: React.FC<IAppRowProps> = ({ app, room }) => {
|
|||
setCanModifyWidget(WidgetUtils.canUserModifyWidgets(room.roomId));
|
||||
}, [room.roomId]);
|
||||
|
||||
const onOpenWidgetClick = () => {
|
||||
const onOpenWidgetClick = (): void => {
|
||||
RightPanelStore.instance.pushCard({
|
||||
phase: RightPanelPhases.Widget,
|
||||
state: { widgetId: app.id },
|
||||
|
@ -216,7 +216,7 @@ const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
|
|||
// Filter out virtual widgets
|
||||
const realApps = useMemo(() => apps.filter((app) => app.eventId !== undefined), [apps]);
|
||||
|
||||
const onManageIntegrations = () => {
|
||||
const onManageIntegrations = (): void => {
|
||||
const managers = IntegrationManagers.sharedInstance();
|
||||
if (!managers.hasManager()) {
|
||||
managers.openNoManagerDialog();
|
||||
|
@ -248,20 +248,20 @@ const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
|
|||
);
|
||||
};
|
||||
|
||||
const onRoomMembersClick = (ev: ButtonEvent) => {
|
||||
const onRoomMembersClick = (ev: ButtonEvent): void => {
|
||||
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.RoomMemberList }, true);
|
||||
PosthogTrackers.trackInteraction("WebRightPanelRoomInfoPeopleButton", ev);
|
||||
};
|
||||
|
||||
const onRoomFilesClick = () => {
|
||||
const onRoomFilesClick = (): void => {
|
||||
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.FilePanel }, true);
|
||||
};
|
||||
|
||||
const onRoomPinsClick = () => {
|
||||
const onRoomPinsClick = (): void => {
|
||||
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.PinnedMessages }, true);
|
||||
};
|
||||
|
||||
const onRoomSettingsClick = (ev: ButtonEvent) => {
|
||||
const onRoomSettingsClick = (ev: ButtonEvent): void => {
|
||||
defaultDispatcher.dispatch({ action: "open_room_settings" });
|
||||
PosthogTrackers.trackInteraction("WebRightPanelRoomInfoSettingsButton", ev);
|
||||
};
|
||||
|
@ -269,13 +269,13 @@ const onRoomSettingsClick = (ev: ButtonEvent) => {
|
|||
const RoomSummaryCard: React.FC<IProps> = ({ room, onClose }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
const onShareRoomClick = () => {
|
||||
const onShareRoomClick = (): void => {
|
||||
Modal.createDialog(ShareDialog, {
|
||||
target: room,
|
||||
});
|
||||
};
|
||||
|
||||
const onRoomExportClick = async () => {
|
||||
const onRoomExportClick = async (): Promise<void> => {
|
||||
Modal.createDialog(ExportDialog, {
|
||||
room,
|
||||
});
|
||||
|
|
|
@ -172,7 +172,7 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
|||
this.setState({ narrow });
|
||||
};
|
||||
|
||||
private jumpToLiveTimeline = () => {
|
||||
private jumpToLiveTimeline = (): void => {
|
||||
if (this.state.initialEventId && this.state.isInitialEventHighlighted) {
|
||||
// If we were viewing a highlighted event, firing view_room without
|
||||
// an event will take care of both clearing the URL fragment and
|
||||
|
|
|
@ -85,7 +85,7 @@ export interface IDevice {
|
|||
getDisplayName(): string;
|
||||
}
|
||||
|
||||
export const disambiguateDevices = (devices: IDevice[]) => {
|
||||
export const disambiguateDevices = (devices: IDevice[]): void => {
|
||||
const names = Object.create(null);
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
const name = devices[i].getDisplayName();
|
||||
|
@ -133,7 +133,12 @@ async function openDMForUser(matrixClient: MatrixClient, user: RoomMember): Prom
|
|||
|
||||
type SetUpdating = (updating: boolean) => void;
|
||||
|
||||
function useHasCrossSigningKeys(cli: MatrixClient, member: User, canVerify: boolean, setUpdating: SetUpdating) {
|
||||
function useHasCrossSigningKeys(
|
||||
cli: MatrixClient,
|
||||
member: User,
|
||||
canVerify: boolean,
|
||||
setUpdating: SetUpdating,
|
||||
): boolean {
|
||||
return useAsyncMemo(async () => {
|
||||
if (!canVerify) {
|
||||
return undefined;
|
||||
|
@ -150,7 +155,7 @@ function useHasCrossSigningKeys(cli: MatrixClient, member: User, canVerify: bool
|
|||
}, [cli, member, canVerify]);
|
||||
}
|
||||
|
||||
export function DeviceItem({ userId, device }: { userId: string; device: IDevice }) {
|
||||
export function DeviceItem({ userId, device }: { userId: string; device: IDevice }): JSX.Element {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const isMe = userId === cli.getUserId();
|
||||
const deviceTrust = cli.checkDeviceTrust(userId, device.deviceId);
|
||||
|
@ -172,7 +177,7 @@ export function DeviceItem({ userId, device }: { userId: string; device: IDevice
|
|||
mx_E2EIcon_warning: userTrust.isVerified() && !isVerified,
|
||||
});
|
||||
|
||||
const onDeviceClick = () => {
|
||||
const onDeviceClick = (): void => {
|
||||
const user = cli.getUser(userId);
|
||||
if (user) {
|
||||
verifyDevice(user, device);
|
||||
|
@ -210,7 +215,15 @@ export function DeviceItem({ userId, device }: { userId: string; device: IDevice
|
|||
}
|
||||
}
|
||||
|
||||
function DevicesSection({ devices, userId, loading }: { devices: IDevice[]; userId: string; loading: boolean }) {
|
||||
function DevicesSection({
|
||||
devices,
|
||||
userId,
|
||||
loading,
|
||||
}: {
|
||||
devices: IDevice[];
|
||||
userId: string;
|
||||
loading: boolean;
|
||||
}): JSX.Element {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const userTrust = cli.checkUserTrust(userId);
|
||||
|
||||
|
@ -298,7 +311,7 @@ function DevicesSection({ devices, userId, loading }: { devices: IDevice[]; user
|
|||
);
|
||||
}
|
||||
|
||||
const MessageButton = ({ member }: { member: RoomMember }) => {
|
||||
const MessageButton = ({ member }: { member: RoomMember }): JSX.Element => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
|
@ -334,7 +347,7 @@ export const UserOptionsSection: React.FC<{
|
|||
|
||||
const isMe = member.userId === cli.getUserId();
|
||||
|
||||
const onShareUserClick = () => {
|
||||
const onShareUserClick = (): void => {
|
||||
Modal.createDialog(ShareDialog, {
|
||||
target: member,
|
||||
});
|
||||
|
@ -343,7 +356,7 @@ export const UserOptionsSection: React.FC<{
|
|||
// Only allow the user to ignore the user if its not ourselves
|
||||
// same goes for jumping to read receipt
|
||||
if (!isMe) {
|
||||
const onIgnoreToggle = () => {
|
||||
const onIgnoreToggle = (): void => {
|
||||
const ignoredUsers = cli.getIgnoredUsers();
|
||||
if (isIgnored) {
|
||||
const index = ignoredUsers.indexOf(member.userId);
|
||||
|
@ -366,7 +379,7 @@ export const UserOptionsSection: React.FC<{
|
|||
);
|
||||
|
||||
if (member.roomId && !isSpace) {
|
||||
const onReadReceiptButton = function () {
|
||||
const onReadReceiptButton = function (): void {
|
||||
const room = cli.getRoom(member.roomId);
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
|
@ -378,7 +391,7 @@ export const UserOptionsSection: React.FC<{
|
|||
});
|
||||
};
|
||||
|
||||
const onInsertPillButton = function () {
|
||||
const onInsertPillButton = function (): void {
|
||||
dis.dispatch<ComposerInsertPayload>({
|
||||
action: Action.ComposerInsert,
|
||||
userId: member.userId,
|
||||
|
@ -404,7 +417,7 @@ export const UserOptionsSection: React.FC<{
|
|||
|
||||
if (canInvite && (member?.membership ?? "leave") === "leave" && shouldShowComponent(UIComponent.InviteUsers)) {
|
||||
const roomId = member && member.roomId ? member.roomId : SdkContextClass.instance.roomViewStore.getRoomId();
|
||||
const onInviteUserButton = async (ev: ButtonEvent) => {
|
||||
const onInviteUserButton = async (ev: ButtonEvent): Promise<void> => {
|
||||
try {
|
||||
// We use a MultiInviter to re-use the invite logic, even though we're only inviting one user.
|
||||
const inviter = new MultiInviter(roomId || "");
|
||||
|
@ -456,8 +469,8 @@ export const UserOptionsSection: React.FC<{
|
|||
);
|
||||
};
|
||||
|
||||
const warnSelfDemote = async (isSpace: boolean) => {
|
||||
const { finished } = Modal.createDialog(QuestionDialog, {
|
||||
const warnSelfDemote = async (isSpace: boolean): Promise<boolean> => {
|
||||
const { finished } = Modal.createDialog<[boolean]>(QuestionDialog, {
|
||||
title: _t("Demote yourself?"),
|
||||
description: (
|
||||
<div>
|
||||
|
@ -503,7 +516,7 @@ interface IPowerLevelsContent {
|
|||
redact?: number;
|
||||
}
|
||||
|
||||
export const isMuted = (member: RoomMember, powerLevelContent: IPowerLevelsContent) => {
|
||||
export const isMuted = (member: RoomMember, powerLevelContent: IPowerLevelsContent): boolean => {
|
||||
if (!powerLevelContent || !member) return false;
|
||||
|
||||
const levelToSend =
|
||||
|
@ -522,7 +535,7 @@ export const isMuted = (member: RoomMember, powerLevelContent: IPowerLevelsConte
|
|||
export const getPowerLevels = (room: Room): IPowerLevelsContent =>
|
||||
room?.currentState?.getStateEvents(EventType.RoomPowerLevels, "")?.getContent() || {};
|
||||
|
||||
export const useRoomPowerLevels = (cli: MatrixClient, room: Room) => {
|
||||
export const useRoomPowerLevels = (cli: MatrixClient, room: Room): IPowerLevelsContent => {
|
||||
const [powerLevels, setPowerLevels] = useState<IPowerLevelsContent>(getPowerLevels(room));
|
||||
|
||||
const update = useCallback(
|
||||
|
@ -550,13 +563,18 @@ interface IBaseProps {
|
|||
stopUpdating(): void;
|
||||
}
|
||||
|
||||
export const RoomKickButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBaseRoomProps, "powerLevels">) => {
|
||||
export const RoomKickButton = ({
|
||||
room,
|
||||
member,
|
||||
startUpdating,
|
||||
stopUpdating,
|
||||
}: Omit<IBaseRoomProps, "powerLevels">): JSX.Element => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
// check if user can be kicked/disinvited
|
||||
if (member.membership !== "invite" && member.membership !== "join") return null;
|
||||
|
||||
const onKick = async () => {
|
||||
const onKick = async (): Promise<void> => {
|
||||
const { finished } = Modal.createDialog(
|
||||
room.isSpaceRoom() ? ConfirmSpaceUserActionDialog : ConfirmUserActionDialog,
|
||||
{
|
||||
|
@ -638,7 +656,7 @@ export const RoomKickButton = ({ room, member, startUpdating, stopUpdating }: Om
|
|||
const RedactMessagesButton: React.FC<IBaseProps> = ({ member }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
const onRedactAllMessages = () => {
|
||||
const onRedactAllMessages = (): void => {
|
||||
const room = cli.getRoom(member.roomId);
|
||||
if (!room) return;
|
||||
|
||||
|
@ -660,11 +678,16 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({ member }) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const BanToggleButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBaseRoomProps, "powerLevels">) => {
|
||||
export const BanToggleButton = ({
|
||||
room,
|
||||
member,
|
||||
startUpdating,
|
||||
stopUpdating,
|
||||
}: Omit<IBaseRoomProps, "powerLevels">): JSX.Element => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
const isBanned = member.membership === "ban";
|
||||
const onBanOrUnban = async () => {
|
||||
const onBanOrUnban = async (): Promise<void> => {
|
||||
const { finished } = Modal.createDialog(
|
||||
room.isSpaceRoom() ? ConfirmSpaceUserActionDialog : ConfirmUserActionDialog,
|
||||
{
|
||||
|
@ -726,7 +749,7 @@ export const BanToggleButton = ({ room, member, startUpdating, stopUpdating }: O
|
|||
|
||||
startUpdating();
|
||||
|
||||
const fn = (roomId: string) => {
|
||||
const fn = (roomId: string): Promise<unknown> => {
|
||||
if (isBanned) {
|
||||
return cli.unban(roomId, member.userId);
|
||||
} else {
|
||||
|
@ -782,7 +805,7 @@ const MuteToggleButton: React.FC<IBaseRoomProps> = ({ member, room, powerLevels,
|
|||
if (member.membership !== "join") return null;
|
||||
|
||||
const muted = isMuted(member, powerLevels);
|
||||
const onMuteToggle = async () => {
|
||||
const onMuteToggle = async (): Promise<void> => {
|
||||
const roomId = member.roomId;
|
||||
const target = member.userId;
|
||||
|
||||
|
@ -918,7 +941,7 @@ export const RoomAdminToolsContainer: React.FC<IBaseRoomProps> = ({
|
|||
return <div />;
|
||||
};
|
||||
|
||||
const useIsSynapseAdmin = (cli: MatrixClient) => {
|
||||
const useIsSynapseAdmin = (cli: MatrixClient): boolean => {
|
||||
const [isAdmin, setIsAdmin] = useState(false);
|
||||
useEffect(() => {
|
||||
cli.isSynapseAdministrator().then(
|
||||
|
@ -933,7 +956,7 @@ const useIsSynapseAdmin = (cli: MatrixClient) => {
|
|||
return isAdmin;
|
||||
};
|
||||
|
||||
const useHomeserverSupportsCrossSigning = (cli: MatrixClient) => {
|
||||
const useHomeserverSupportsCrossSigning = (cli: MatrixClient): boolean => {
|
||||
return useAsyncMemo<boolean>(
|
||||
async () => {
|
||||
return cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");
|
||||
|
@ -1039,7 +1062,7 @@ export const PowerLevelEditor: React.FC<{
|
|||
target: string,
|
||||
powerLevel: number,
|
||||
powerLevelEvent: MatrixEvent,
|
||||
) => {
|
||||
): Promise<unknown> => {
|
||||
return cli.setPowerLevel(roomId, target, powerLevel, powerLevelEvent).then(
|
||||
function () {
|
||||
// NO-OP; rely on the m.room.member event coming down else we could
|
||||
|
@ -1112,7 +1135,7 @@ export const PowerLevelEditor: React.FC<{
|
|||
);
|
||||
};
|
||||
|
||||
export const useDevices = (userId: string) => {
|
||||
export const useDevices = (userId: string): IDevice[] | undefined | null => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
// undefined means yet to be loaded, null means failed to load, otherwise list of devices
|
||||
|
@ -1123,7 +1146,7 @@ export const useDevices = (userId: string) => {
|
|||
|
||||
let cancelled = false;
|
||||
|
||||
async function downloadDeviceList() {
|
||||
async function downloadDeviceList(): Promise<void> {
|
||||
try {
|
||||
await cli.downloadKeys([userId], true);
|
||||
const devices = cli.getStoredDevicesForUser(userId);
|
||||
|
@ -1150,20 +1173,20 @@ export const useDevices = (userId: string) => {
|
|||
// Listen to changes
|
||||
useEffect(() => {
|
||||
let cancel = false;
|
||||
const updateDevices = async () => {
|
||||
const updateDevices = async (): Promise<void> => {
|
||||
const newDevices = cli.getStoredDevicesForUser(userId);
|
||||
if (cancel) return;
|
||||
setDevices(newDevices as IDevice[]);
|
||||
};
|
||||
const onDevicesUpdated = (users: string[]) => {
|
||||
const onDevicesUpdated = (users: string[]): void => {
|
||||
if (!users.includes(userId)) return;
|
||||
updateDevices();
|
||||
};
|
||||
const onDeviceVerificationChanged = (_userId: string, deviceId: string) => {
|
||||
const onDeviceVerificationChanged = (_userId: string, deviceId: string): void => {
|
||||
if (_userId !== userId) return;
|
||||
updateDevices();
|
||||
};
|
||||
const onUserTrustStatusChanged = (_userId: string, trustLevel: UserTrustLevel) => {
|
||||
const onUserTrustStatusChanged = (_userId: string, trustLevel: UserTrustLevel): void => {
|
||||
if (_userId !== userId) return;
|
||||
updateDevices();
|
||||
};
|
||||
|
@ -1559,7 +1582,7 @@ const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPha
|
|||
cardState = { spaceId: room.roomId };
|
||||
}
|
||||
|
||||
const onEncryptionPanelClose = () => {
|
||||
const onEncryptionPanelClose = (): void => {
|
||||
RightPanelStore.instance.popCard();
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
|||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
import { SAS, SasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
|
||||
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
import VerificationQRCode from "../elements/crypto/VerificationQRCode";
|
||||
|
@ -62,7 +63,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
this.hasVerifier = false;
|
||||
}
|
||||
|
||||
private renderQRPhase() {
|
||||
private renderQRPhase(): JSX.Element {
|
||||
const { member, request } = this.props;
|
||||
const showSAS: boolean = request.otherPartySupportsMethod(verificationMethods.SAS);
|
||||
const showQR: boolean = request.otherPartySupportsMethod(SCAN_QR_CODE_METHOD);
|
||||
|
@ -187,22 +188,22 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
);
|
||||
}
|
||||
|
||||
private onReciprocateYesClick = () => {
|
||||
private onReciprocateYesClick = (): void => {
|
||||
this.setState({ reciprocateButtonClicked: true });
|
||||
this.state.reciprocateQREvent.confirm();
|
||||
};
|
||||
|
||||
private onReciprocateNoClick = () => {
|
||||
private onReciprocateNoClick = (): void => {
|
||||
this.setState({ reciprocateButtonClicked: true });
|
||||
this.state.reciprocateQREvent.cancel();
|
||||
};
|
||||
|
||||
private getDevice() {
|
||||
private getDevice(): DeviceInfo {
|
||||
const deviceId = this.props.request && this.props.request.channel.deviceId;
|
||||
return MatrixClientPeg.get().getStoredDevice(MatrixClientPeg.get().getUserId(), deviceId);
|
||||
}
|
||||
|
||||
private renderQRReciprocatePhase() {
|
||||
private renderQRReciprocatePhase(): JSX.Element {
|
||||
const { member, request } = this.props;
|
||||
const description = request.isSelfVerification
|
||||
? _t("Almost there! Is your other device showing the same shield?")
|
||||
|
@ -249,7 +250,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
);
|
||||
}
|
||||
|
||||
private renderVerifiedPhase() {
|
||||
private renderVerifiedPhase(): JSX.Element {
|
||||
const { member, request } = this.props;
|
||||
|
||||
let text: string;
|
||||
|
@ -293,7 +294,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
);
|
||||
}
|
||||
|
||||
private renderCancelledPhase() {
|
||||
private renderCancelledPhase(): JSX.Element {
|
||||
const { member, request } = this.props;
|
||||
|
||||
let startAgainInstruction: string;
|
||||
|
@ -331,7 +332,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
);
|
||||
}
|
||||
|
||||
public render() {
|
||||
public render(): JSX.Element {
|
||||
const { member, phase, request } = this.props;
|
||||
|
||||
const displayName = (member as User).displayName || (member as RoomMember).name || member.userId;
|
||||
|
@ -371,7 +372,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
return null;
|
||||
}
|
||||
|
||||
private startSAS = async () => {
|
||||
private startSAS = async (): Promise<void> => {
|
||||
this.setState({ emojiButtonClicked: true });
|
||||
const verifier = this.props.request.beginKeyVerification(verificationMethods.SAS);
|
||||
try {
|
||||
|
@ -381,15 +382,15 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
}
|
||||
};
|
||||
|
||||
private onSasMatchesClick = () => {
|
||||
private onSasMatchesClick = (): void => {
|
||||
this.state.sasEvent.confirm();
|
||||
};
|
||||
|
||||
private onSasMismatchesClick = () => {
|
||||
private onSasMismatchesClick = (): void => {
|
||||
this.state.sasEvent.mismatch();
|
||||
};
|
||||
|
||||
private updateVerifierState = () => {
|
||||
private updateVerifierState = (): void => {
|
||||
const { request } = this.props;
|
||||
const sasEvent = (request.verifier as SAS).sasEvent;
|
||||
const reciprocateQREvent = (request.verifier as ReciprocateQRCode).reciprocateQREvent;
|
||||
|
@ -398,7 +399,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
this.setState({ sasEvent, reciprocateQREvent });
|
||||
};
|
||||
|
||||
private onRequestChange = async () => {
|
||||
private onRequestChange = async (): Promise<void> => {
|
||||
const { request } = this.props;
|
||||
const hadVerifier = this.hasVerifier;
|
||||
this.hasVerifier = !!request.verifier;
|
||||
|
@ -415,7 +416,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
}
|
||||
};
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
const { request } = this.props;
|
||||
request.on(VerificationRequestEvent.Change, this.onRequestChange);
|
||||
if (request.verifier) {
|
||||
|
@ -426,7 +427,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
|
|||
this.onRequestChange();
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
public componentWillUnmount(): void {
|
||||
const { request } = this.props;
|
||||
if (request.verifier) {
|
||||
request.verifier.off(SasEvent.ShowSas, this.updateVerifierState);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue