Strictify RoomView.tsx (#11163)
This commit is contained in:
parent
9fa58e4e90
commit
3fb4dac6fc
1 changed files with 39 additions and 15 deletions
|
@ -117,6 +117,7 @@ import { WidgetType } from "../../widgets/WidgetType";
|
||||||
import WidgetUtils from "../../utils/WidgetUtils";
|
import WidgetUtils from "../../utils/WidgetUtils";
|
||||||
import { shouldEncryptRoomWithSingle3rdPartyInvite } from "../../utils/room/shouldEncryptRoomWithSingle3rdPartyInvite";
|
import { shouldEncryptRoomWithSingle3rdPartyInvite } from "../../utils/room/shouldEncryptRoomWithSingle3rdPartyInvite";
|
||||||
import { WaitingForThirdPartyRoomView } from "./WaitingForThirdPartyRoomView";
|
import { WaitingForThirdPartyRoomView } from "./WaitingForThirdPartyRoomView";
|
||||||
|
import { isNotUndefined } from "../../Typeguards";
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
const PREVENT_MULTIPLE_JITSI_WITHIN = 30_000;
|
const PREVENT_MULTIPLE_JITSI_WITHIN = 30_000;
|
||||||
|
@ -809,7 +810,21 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
return this.state.room?.roomId ?? this.state.roomId;
|
return this.state.room?.roomId ?? this.state.roomId;
|
||||||
};
|
};
|
||||||
|
|
||||||
private getPermalinkCreatorForRoom(room: Room): RoomPermalinkCreator {
|
private getPermalinkCreatorForRoom(): RoomPermalinkCreator {
|
||||||
|
const { room, roomId } = this.state;
|
||||||
|
|
||||||
|
// If room is undefined, attempt to use the roomId to create and store a permalinkCreator.
|
||||||
|
// Throw an error if we can not find a roomId in state.
|
||||||
|
if (room === undefined) {
|
||||||
|
if (isNotUndefined(roomId)) {
|
||||||
|
const permalinkCreator = new RoomPermalinkCreator(null, roomId);
|
||||||
|
this.permalinkCreators[roomId] = permalinkCreator;
|
||||||
|
return permalinkCreator;
|
||||||
|
} else {
|
||||||
|
throw new Error("Cannot get a permalink creator without a roomId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.permalinkCreators[room.roomId]) return this.permalinkCreators[room.roomId];
|
if (this.permalinkCreators[room.roomId]) return this.permalinkCreators[room.roomId];
|
||||||
|
|
||||||
this.permalinkCreators[room.roomId] = new RoomPermalinkCreator(room);
|
this.permalinkCreators[room.roomId] = new RoomPermalinkCreator(room);
|
||||||
|
@ -1096,14 +1111,19 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
payload.data.threadId,
|
payload.data.threadId,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "picture_snapshot":
|
case "picture_snapshot": {
|
||||||
|
const roomId = this.getRoomId();
|
||||||
|
if (isNotUndefined(roomId)) {
|
||||||
ContentMessages.sharedInstance().sendContentListToRoom(
|
ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
[payload.file],
|
[payload.file],
|
||||||
this.getRoomId(),
|
roomId,
|
||||||
undefined,
|
undefined,
|
||||||
this.context.client,
|
this.context.client,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "notifier_enabled":
|
case "notifier_enabled":
|
||||||
case Action.UploadStarted:
|
case Action.UploadStarted:
|
||||||
case Action.UploadFinished:
|
case Action.UploadFinished:
|
||||||
|
@ -1552,12 +1572,16 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
} else {
|
} else {
|
||||||
Promise.resolve().then(() => {
|
Promise.resolve().then(() => {
|
||||||
const signUrl = this.props.threepidInvite?.signUrl;
|
const signUrl = this.props.threepidInvite?.signUrl;
|
||||||
|
const roomId = this.getRoomId();
|
||||||
|
if (isNotUndefined(roomId)) {
|
||||||
dis.dispatch<JoinRoomPayload>({
|
dis.dispatch<JoinRoomPayload>({
|
||||||
action: Action.JoinRoom,
|
action: Action.JoinRoom,
|
||||||
roomId: this.getRoomId(),
|
roomId,
|
||||||
opts: { inviteSignUrl: signUrl },
|
opts: { inviteSignUrl: signUrl },
|
||||||
metricsTrigger: this.state.room?.getMyMembership() === "invite" ? "Invite" : "RoomPreview",
|
metricsTrigger: this.state.room?.getMyMembership() === "invite" ? "Invite" : "RoomPreview",
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1920,7 +1944,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private get permalinkCreator(): RoomPermalinkCreator {
|
private get permalinkCreator(): RoomPermalinkCreator {
|
||||||
return this.getPermalinkCreatorForRoom(this.state.room);
|
return this.getPermalinkCreatorForRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderLocalRoomCreateLoader(localRoom: LocalRoom): ReactNode {
|
private renderLocalRoomCreateLoader(localRoom: LocalRoom): ReactNode {
|
||||||
|
|
Loading…
Reference in a new issue