Conform more of the codebase to strictNullChecks
(#10738)
This commit is contained in:
parent
5e8488c283
commit
52017f62e1
18 changed files with 105 additions and 84 deletions
|
@ -62,7 +62,7 @@
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@matrix-org/analytics-events": "^0.5.0",
|
"@matrix-org/analytics-events": "^0.5.0",
|
||||||
"@matrix-org/matrix-wysiwyg": "^2.0.0",
|
"@matrix-org/matrix-wysiwyg": "^2.0.0",
|
||||||
"@matrix-org/react-sdk-module-api": "^0.0.4",
|
"@matrix-org/react-sdk-module-api": "^0.0.5",
|
||||||
"@sentry/browser": "^7.0.0",
|
"@sentry/browser": "^7.0.0",
|
||||||
"@sentry/tracing": "^7.0.0",
|
"@sentry/tracing": "^7.0.0",
|
||||||
"@testing-library/react-hooks": "^8.0.1",
|
"@testing-library/react-hooks": "^8.0.1",
|
||||||
|
|
|
@ -711,8 +711,8 @@ export default class LegacyCallHandler extends EventEmitter {
|
||||||
// Don't show a modal when we got rejected/the call was hung up
|
// Don't show a modal when we got rejected/the call was hung up
|
||||||
if (!hangupReason || [CallErrorCode.UserHangup, "user hangup"].includes(hangupReason)) break;
|
if (!hangupReason || [CallErrorCode.UserHangup, "user hangup"].includes(hangupReason)) break;
|
||||||
|
|
||||||
let title;
|
let title: string;
|
||||||
let description;
|
let description: string;
|
||||||
// TODO: We should either do away with these or figure out a copy for each code (expect user_hangup...)
|
// TODO: We should either do away with these or figure out a copy for each code (expect user_hangup...)
|
||||||
if (call.hangupReason === CallErrorCode.UserBusy) {
|
if (call.hangupReason === CallErrorCode.UserBusy) {
|
||||||
title = _t("User Busy");
|
title = _t("User Busy");
|
||||||
|
@ -1094,8 +1094,10 @@ export default class LegacyCallHandler extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const roomId = await ensureDMExists(MatrixClientPeg.get(), nativeUserId);
|
const roomId = await ensureDMExists(MatrixClientPeg.get(), nativeUserId);
|
||||||
|
if (!roomId) {
|
||||||
|
throw new Error("Failed to ensure DM exists for dialing number");
|
||||||
|
}
|
||||||
|
|
||||||
if (isNotNull(roomId)) {
|
|
||||||
dis.dispatch<ViewRoomPayload>({
|
dis.dispatch<ViewRoomPayload>({
|
||||||
action: Action.ViewRoom,
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
|
@ -1104,7 +1106,6 @@ export default class LegacyCallHandler extends EventEmitter {
|
||||||
|
|
||||||
await this.placeMatrixCall(roomId, CallType.Voice, transferee);
|
await this.placeMatrixCall(roomId, CallType.Voice, transferee);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async startTransferToPhoneNumber(
|
public async startTransferToPhoneNumber(
|
||||||
call: MatrixCall,
|
call: MatrixCall,
|
||||||
|
|
|
@ -197,8 +197,14 @@ class NotifierClass {
|
||||||
|
|
||||||
// Ideally in here we could use MSC1310 to detect the type of file, and reject it.
|
// Ideally in here we could use MSC1310 to detect the type of file, and reject it.
|
||||||
|
|
||||||
|
const url = mediaFromMxc(content.url).srcHttp;
|
||||||
|
if (!url) {
|
||||||
|
logger.warn("Something went wrong when generating src http url for mxc");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: mediaFromMxc(content.url).srcHttp,
|
url,
|
||||||
name: content.name,
|
name: content.name,
|
||||||
type: content.type,
|
type: content.type,
|
||||||
size: content.size,
|
size: content.size,
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default class RoomListActions {
|
||||||
newTag: TagID | null,
|
newTag: TagID | null,
|
||||||
newIndex: number,
|
newIndex: number,
|
||||||
): AsyncActionPayload {
|
): AsyncActionPayload {
|
||||||
let metaData: Parameters<MatrixClient["setRoomTag"]>[2] | null = null;
|
let metaData: Parameters<MatrixClient["setRoomTag"]>[2] | undefined;
|
||||||
|
|
||||||
// Is the tag ordered manually?
|
// Is the tag ordered manually?
|
||||||
const store = RoomListStore.instance;
|
const store = RoomListStore.instance;
|
||||||
|
@ -113,10 +113,6 @@ export default class RoomListActions {
|
||||||
|
|
||||||
// if we moved lists or the ordering changed, add the new tag
|
// if we moved lists or the ordering changed, add the new tag
|
||||||
if (newTag && newTag !== DefaultTagID.DM && (hasChangedSubLists || metaData)) {
|
if (newTag && newTag !== DefaultTagID.DM && (hasChangedSubLists || metaData)) {
|
||||||
// metaData is the body of the PUT to set the tag, so it must
|
|
||||||
// at least be an empty object.
|
|
||||||
metaData = metaData || ({} as typeof metaData);
|
|
||||||
|
|
||||||
const promiseToAdd = matrixClient.setRoomTag(roomId, newTag, metaData).catch(function (err) {
|
const promiseToAdd = matrixClient.setRoomTag(roomId, newTag, metaData).catch(function (err) {
|
||||||
logger.error("Failed to add tag " + newTag + " to room: " + err);
|
logger.error("Failed to add tag " + newTag + " to room: " + err);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
|
|
|
@ -71,7 +71,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
||||||
removed: boolean,
|
removed: boolean,
|
||||||
data: IRoomTimelineData,
|
data: IRoomTimelineData,
|
||||||
): void => {
|
): void => {
|
||||||
if (room?.roomId !== this.props?.roomId) return;
|
if (room?.roomId !== this.props.roomId) return;
|
||||||
if (toStartOfTimeline || !data || !data.liveEvent || ev.isRedacted()) return;
|
if (toStartOfTimeline || !data || !data.liveEvent || ev.isRedacted()) return;
|
||||||
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
|
|
|
@ -164,7 +164,7 @@ interface IProps {
|
||||||
onNewScreen: (screen: string, replaceLast: boolean) => void;
|
onNewScreen: (screen: string, replaceLast: boolean) => void;
|
||||||
enableGuest?: boolean;
|
enableGuest?: boolean;
|
||||||
// the queryParams extracted from the [real] query-string of the URI
|
// the queryParams extracted from the [real] query-string of the URI
|
||||||
realQueryParams?: QueryDict;
|
realQueryParams: QueryDict;
|
||||||
// the initial queryParams extracted from the hash-fragment of the URI
|
// the initial queryParams extracted from the hash-fragment of the URI
|
||||||
startingFragmentQueryParams?: QueryDict;
|
startingFragmentQueryParams?: QueryDict;
|
||||||
// called when we have completed a token login
|
// called when we have completed a token login
|
||||||
|
|
|
@ -97,7 +97,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cardState: currentCard?.state,
|
cardState: currentCard?.state,
|
||||||
phase: currentCard?.phase,
|
phase: currentCard?.phase ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
this.delayedUpdate();
|
this.delayedUpdate();
|
||||||
} else if (
|
} else if (
|
||||||
this.state.phase === RightPanelPhases.RoomMemberInfo &&
|
this.state.phase === RightPanelPhases.RoomMemberInfo &&
|
||||||
member.userId === this.state.cardState.member?.userId
|
member.userId === this.state.cardState?.member?.userId
|
||||||
) {
|
) {
|
||||||
// refresh the member info (e.g. new power level)
|
// refresh the member info (e.g. new power level)
|
||||||
this.delayedUpdate();
|
this.delayedUpdate();
|
||||||
|
@ -156,7 +156,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
const cardState = this.props.overwriteCard?.state ?? this.state.cardState;
|
const cardState = this.props.overwriteCard?.state ?? this.state.cardState;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case RightPanelPhases.RoomMemberList:
|
case RightPanelPhases.RoomMemberList:
|
||||||
if (roomId) {
|
if (!!roomId) {
|
||||||
card = (
|
card = (
|
||||||
<MemberList
|
<MemberList
|
||||||
roomId={roomId}
|
roomId={roomId}
|
||||||
|
@ -199,7 +199,9 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
case RightPanelPhases.Room3pidMemberInfo:
|
case RightPanelPhases.Room3pidMemberInfo:
|
||||||
case RightPanelPhases.Space3pidMemberInfo:
|
case RightPanelPhases.Space3pidMemberInfo:
|
||||||
card = <ThirdPartyMemberInfo event={cardState?.memberInfoEvent} key={roomId} />;
|
if (!!cardState?.memberInfoEvent) {
|
||||||
|
card = <ThirdPartyMemberInfo event={cardState.memberInfoEvent} key={roomId} />;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RightPanelPhases.NotificationPanel:
|
case RightPanelPhases.NotificationPanel:
|
||||||
|
@ -207,7 +209,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RightPanelPhases.PinnedMessages:
|
case RightPanelPhases.PinnedMessages:
|
||||||
if (this.props.room && SettingsStore.getValue("feature_pinning")) {
|
if (!!this.props.room && SettingsStore.getValue("feature_pinning")) {
|
||||||
card = (
|
card = (
|
||||||
<PinnedMessagesCard
|
<PinnedMessagesCard
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
|
@ -218,7 +220,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RightPanelPhases.Timeline:
|
case RightPanelPhases.Timeline:
|
||||||
if (this.props.room) {
|
if (!!this.props.room) {
|
||||||
card = (
|
card = (
|
||||||
<TimelineCard
|
<TimelineCard
|
||||||
classNames="mx_ThreadPanel mx_TimelineCard"
|
classNames="mx_ThreadPanel mx_TimelineCard"
|
||||||
|
@ -233,20 +235,24 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RightPanelPhases.FilePanel:
|
case RightPanelPhases.FilePanel:
|
||||||
card = <FilePanel roomId={roomId} resizeNotifier={this.props.resizeNotifier} onClose={this.onClose} />;
|
if (!!roomId) {
|
||||||
|
card = (
|
||||||
|
<FilePanel roomId={roomId} resizeNotifier={this.props.resizeNotifier} onClose={this.onClose} />
|
||||||
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RightPanelPhases.ThreadView:
|
case RightPanelPhases.ThreadView:
|
||||||
if (this.props.room) {
|
if (!!this.props.room && !!cardState?.threadHeadEvent) {
|
||||||
card = (
|
card = (
|
||||||
<ThreadView
|
<ThreadView
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
resizeNotifier={this.props.resizeNotifier}
|
resizeNotifier={this.props.resizeNotifier}
|
||||||
onClose={this.onClose}
|
onClose={this.onClose}
|
||||||
mxEvent={cardState?.threadHeadEvent}
|
mxEvent={cardState.threadHeadEvent}
|
||||||
initialEvent={cardState?.initialEvent}
|
initialEvent={cardState.initialEvent}
|
||||||
isInitialEventHighlighted={cardState?.isInitialEventHighlighted}
|
isInitialEventHighlighted={cardState.isInitialEventHighlighted}
|
||||||
initialEventScrollIntoView={cardState?.initialEventScrollIntoView}
|
initialEventScrollIntoView={cardState.initialEventScrollIntoView}
|
||||||
permalinkCreator={this.props.permalinkCreator}
|
permalinkCreator={this.props.permalinkCreator}
|
||||||
e2eStatus={this.props.e2eStatus}
|
e2eStatus={this.props.e2eStatus}
|
||||||
/>
|
/>
|
||||||
|
@ -255,6 +261,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RightPanelPhases.ThreadPanel:
|
case RightPanelPhases.ThreadPanel:
|
||||||
|
if (!!roomId) {
|
||||||
card = (
|
card = (
|
||||||
<ThreadPanel
|
<ThreadPanel
|
||||||
roomId={roomId}
|
roomId={roomId}
|
||||||
|
@ -263,10 +270,11 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
permalinkCreator={this.props.permalinkCreator}
|
permalinkCreator={this.props.permalinkCreator}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RightPanelPhases.RoomSummary:
|
case RightPanelPhases.RoomSummary:
|
||||||
if (this.props.room) {
|
if (!!this.props.room) {
|
||||||
card = (
|
card = (
|
||||||
<RoomSummaryCard
|
<RoomSummaryCard
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
|
@ -279,8 +287,8 @@ export default class RightPanel extends React.Component<IProps, IState> {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RightPanelPhases.Widget:
|
case RightPanelPhases.Widget:
|
||||||
if (this.props.room) {
|
if (!!this.props.room && !!cardState?.widgetId) {
|
||||||
card = <WidgetCard room={this.props.room} widgetId={cardState?.widgetId} onClose={this.onClose} />;
|
card = <WidgetCard room={this.props.room} widgetId={cardState.widgetId} onClose={this.onClose} />;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,7 +626,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
wasContextSwitch: this.context.roomViewStore.getWasContextSwitch(),
|
wasContextSwitch: this.context.roomViewStore.getWasContextSwitch(),
|
||||||
mainSplitContentType: room ? this.getMainSplitContentType(room) : undefined,
|
mainSplitContentType: room ? this.getMainSplitContentType(room) : undefined,
|
||||||
initialEventId: undefined, // default to clearing this, will get set later in the method if needed
|
initialEventId: undefined, // default to clearing this, will get set later in the method if needed
|
||||||
showRightPanel: this.context.rightPanelStore.isOpenForRoom(roomId),
|
showRightPanel: roomId ? this.context.rightPanelStore.isOpenForRoom(roomId) : false,
|
||||||
activeCall: roomId ? CallStore.instance.getActiveCall(roomId) : null,
|
activeCall: roomId ? CallStore.instance.getActiveCall(roomId) : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
newState.initialEventPixelOffset = undefined;
|
newState.initialEventPixelOffset = undefined;
|
||||||
|
|
||||||
const thread = initialEvent?.getThread();
|
const thread = initialEvent?.getThread();
|
||||||
if (thread && !initialEvent?.isThreadRoot) {
|
if (thread?.rootEvent && !initialEvent?.isThreadRoot) {
|
||||||
dis.dispatch<ShowThreadPayload>({
|
dis.dispatch<ShowThreadPayload>({
|
||||||
action: Action.ShowThread,
|
action: Action.ShowThread,
|
||||||
rootEvent: thread.rootEvent,
|
rootEvent: thread.rootEvent,
|
||||||
|
@ -675,7 +675,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
newState.isInitialEventHighlighted = this.context.roomViewStore.isInitialEventHighlighted();
|
newState.isInitialEventHighlighted = this.context.roomViewStore.isInitialEventHighlighted();
|
||||||
newState.initialEventScrollIntoView = this.context.roomViewStore.initialEventScrollIntoView();
|
newState.initialEventScrollIntoView = this.context.roomViewStore.initialEventScrollIntoView();
|
||||||
|
|
||||||
if (thread && initialEvent?.isThreadRoot) {
|
if (thread?.rootEvent && initialEvent?.isThreadRoot) {
|
||||||
dis.dispatch<ShowThreadPayload>({
|
dis.dispatch<ShowThreadPayload>({
|
||||||
action: Action.ShowThread,
|
action: Action.ShowThread,
|
||||||
rootEvent: thread.rootEvent,
|
rootEvent: thread.rootEvent,
|
||||||
|
@ -1016,7 +1016,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
|
|
||||||
private onRightPanelStoreUpdate = (): void => {
|
private onRightPanelStoreUpdate = (): void => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showRightPanel: this.context.rightPanelStore.isOpenForRoom(this.state.roomId),
|
showRightPanel: this.state.roomId ? this.context.rightPanelStore.isOpenForRoom(this.state.roomId) : false,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1087,7 +1087,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
case "picture_snapshot":
|
case "picture_snapshot":
|
||||||
ContentMessages.sharedInstance().sendContentListToRoom(
|
ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
[payload.file],
|
[payload.file],
|
||||||
this.state.room.roomId,
|
this.getRoomId(),
|
||||||
undefined,
|
undefined,
|
||||||
this.context.client,
|
this.context.client,
|
||||||
);
|
);
|
||||||
|
@ -1496,6 +1496,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
);
|
);
|
||||||
|
|
||||||
private checkDesktopNotifications(): void {
|
private checkDesktopNotifications(): void {
|
||||||
|
if (!this.state.room) return;
|
||||||
const memberCount = this.state.room.getJoinedMemberCount() + this.state.room.getInvitedMemberCount();
|
const memberCount = this.state.room.getJoinedMemberCount() + this.state.room.getInvitedMemberCount();
|
||||||
// if they are not alone prompt the user about notifications so they don't miss replies
|
// if they are not alone prompt the user about notifications so they don't miss replies
|
||||||
if (memberCount > 1 && Notifier.shouldShowPrompt()) {
|
if (memberCount > 1 && Notifier.shouldShowPrompt()) {
|
||||||
|
@ -1518,7 +1519,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
// open the room inviter
|
// open the room inviter
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_invite",
|
action: "view_invite",
|
||||||
roomId: this.state.room.roomId,
|
roomId: this.getRoomId(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1588,7 +1589,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
debuglog("Removing scroll_into_view flag from initial event");
|
debuglog("Removing scroll_into_view flag from initial event");
|
||||||
dis.dispatch<ViewRoomPayload>({
|
dis.dispatch<ViewRoomPayload>({
|
||||||
action: Action.ViewRoom,
|
action: Action.ViewRoom,
|
||||||
room_id: this.state.room.roomId,
|
room_id: this.getRoomId(),
|
||||||
event_id: this.state.initialEventId,
|
event_id: this.state.initialEventId,
|
||||||
highlighted: this.state.isInitialEventHighlighted,
|
highlighted: this.state.isInitialEventHighlighted,
|
||||||
scroll_into_view: false,
|
scroll_into_view: false,
|
||||||
|
@ -1606,7 +1607,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentMessages.sharedInstance()
|
ContentMessages.sharedInstance()
|
||||||
.sendStickerContentToRoom(url, this.state.room.roomId, threadId, info, text, this.context.client)
|
.sendStickerContentToRoom(url, this.getRoomId(), threadId, info, text, this.context.client)
|
||||||
.then(undefined, (error) => {
|
.then(undefined, (error) => {
|
||||||
if (error.name === "UnknownDeviceError") {
|
if (error.name === "UnknownDeviceError") {
|
||||||
// Let the staus bar handle this
|
// Let the staus bar handle this
|
||||||
|
@ -1616,7 +1617,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private onSearch = (term: string, scope: SearchScope): void => {
|
private onSearch = (term: string, scope: SearchScope): void => {
|
||||||
const roomId = scope === SearchScope.Room ? this.state.room.roomId : undefined;
|
const roomId = scope === SearchScope.Room ? this.getRoomId() : undefined;
|
||||||
debuglog("sending search request");
|
debuglog("sending search request");
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
const promise = eventSearch(term, roomId, abortController.signal);
|
const promise = eventSearch(term, roomId, abortController.signal);
|
||||||
|
@ -1655,7 +1656,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
private onForgetClick = (): void => {
|
private onForgetClick = (): void => {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "forget_room",
|
action: "forget_room",
|
||||||
room_id: this.state.room.roomId,
|
room_id: this.getRoomId(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1663,7 +1664,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
this.setState({
|
this.setState({
|
||||||
rejecting: true,
|
rejecting: true,
|
||||||
});
|
});
|
||||||
this.context.client?.leave(this.state.roomId).then(
|
this.context.client?.leave(this.getRoomId()).then(
|
||||||
() => {
|
() => {
|
||||||
dis.dispatch({ action: Action.ViewHomePage });
|
dis.dispatch({ action: Action.ViewHomePage });
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1757,7 +1758,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
// jumping to the bottom
|
// jumping to the bottom
|
||||||
dis.dispatch<ViewRoomPayload>({
|
dis.dispatch<ViewRoomPayload>({
|
||||||
action: Action.ViewRoom,
|
action: Action.ViewRoom,
|
||||||
room_id: this.state.room.roomId,
|
room_id: this.getRoomId(),
|
||||||
metricsTrigger: undefined, // room doesn't change
|
metricsTrigger: undefined, // room doesn't change
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1903,7 +1904,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
private onFileDrop = (dataTransfer: DataTransfer): Promise<void> =>
|
private onFileDrop = (dataTransfer: DataTransfer): Promise<void> =>
|
||||||
ContentMessages.sharedInstance().sendContentListToRoom(
|
ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
Array.from(dataTransfer.files),
|
Array.from(dataTransfer.files),
|
||||||
this.state.room?.roomId ?? this.state.roomId,
|
this.getRoomId(),
|
||||||
null,
|
null,
|
||||||
this.context.client,
|
this.context.client,
|
||||||
TimelineRenderingType.Room,
|
TimelineRenderingType.Room,
|
||||||
|
@ -1921,7 +1922,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
return this.getPermalinkCreatorForRoom(this.state.room);
|
return this.getPermalinkCreatorForRoom(this.state.room);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderLocalRoomCreateLoader(localRoom: LocalRoom): ReactElement {
|
private renderLocalRoomCreateLoader(localRoom: LocalRoom): ReactNode {
|
||||||
|
if (!this.state.room || !this.context?.client) return null;
|
||||||
const names = this.state.room.getDefaultRoomName(this.context.client.getSafeUserId());
|
const names = this.state.room.getDefaultRoomName(this.context.client.getSafeUserId());
|
||||||
return (
|
return (
|
||||||
<RoomContext.Provider value={this.state}>
|
<RoomContext.Provider value={this.state}>
|
||||||
|
@ -1930,7 +1932,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderLocalRoomView(localRoom: LocalRoom): ReactElement {
|
private renderLocalRoomView(localRoom: LocalRoom): ReactNode {
|
||||||
return (
|
return (
|
||||||
<RoomContext.Provider value={this.state}>
|
<RoomContext.Provider value={this.state}>
|
||||||
<LocalRoomView
|
<LocalRoomView
|
||||||
|
@ -1944,7 +1946,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderWaitingForThirdPartyRoomView(inviteEvent: MatrixEvent): ReactElement {
|
private renderWaitingForThirdPartyRoomView(inviteEvent: MatrixEvent): ReactNode {
|
||||||
return (
|
return (
|
||||||
<RoomContext.Provider value={this.state}>
|
<RoomContext.Provider value={this.state}>
|
||||||
<WaitingForThirdPartyRoomView
|
<WaitingForThirdPartyRoomView
|
||||||
|
@ -1956,7 +1958,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): ReactNode {
|
||||||
if (!this.context.client) return null;
|
if (!this.context.client) return null;
|
||||||
|
|
||||||
if (this.state.room instanceof LocalRoom) {
|
if (this.state.room instanceof LocalRoom) {
|
||||||
|
|
|
@ -1023,7 +1023,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
shouldSendRR &&
|
shouldSendRR &&
|
||||||
// Only send a RR if the last read event is ahead in the timeline relative to
|
// Only send a RR if the last read event is ahead in the timeline relative to
|
||||||
// the current RR event.
|
// the current RR event.
|
||||||
lastReadEventIndex > currentRREventIndex &&
|
lastReadEventIndex! > currentRREventIndex! &&
|
||||||
// Only send a RR if the last RR set != the one we would send
|
// Only send a RR if the last RR set != the one we would send
|
||||||
this.lastRRSentEventId !== lastReadEvent?.getId();
|
this.lastRRSentEventId !== lastReadEvent?.getId();
|
||||||
|
|
||||||
|
@ -1307,7 +1307,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
const pos = this.getReadMarkerPosition();
|
const pos = this.getReadMarkerPosition();
|
||||||
const ret =
|
const ret =
|
||||||
this.state.readMarkerEventId !== null && // 1.
|
this.state.readMarkerEventId !== null && // 1.
|
||||||
(pos < 0 || pos === null); // 3., 4.
|
(pos === null || pos < 0); // 3., 4.
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1351,7 +1351,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
"TimelinePanel scrolling to eventId " +
|
"TimelinePanel scrolling to eventId " +
|
||||||
eventId +
|
eventId +
|
||||||
" at position " +
|
" at position " +
|
||||||
offsetBase * 100 +
|
offsetBase! * 100 +
|
||||||
"% + " +
|
"% + " +
|
||||||
pixelOffset,
|
pixelOffset,
|
||||||
);
|
);
|
||||||
|
|
|
@ -64,7 +64,7 @@ interface IOptionsButtonProps {
|
||||||
// TODO: Types
|
// TODO: Types
|
||||||
getTile: () => any | null;
|
getTile: () => any | null;
|
||||||
getReplyChain: () => ReplyChain | null;
|
getReplyChain: () => ReplyChain | null;
|
||||||
permalinkCreator: RoomPermalinkCreator;
|
permalinkCreator?: RoomPermalinkCreator;
|
||||||
onFocusChange: (menuDisplayed: boolean) => void;
|
onFocusChange: (menuDisplayed: boolean) => void;
|
||||||
getRelationsForEvent?: GetRelationsForEvent;
|
getRelationsForEvent?: GetRelationsForEvent;
|
||||||
}
|
}
|
||||||
|
@ -208,10 +208,11 @@ const ReplyInThreadButton: React.FC<IReplyInThreadButton> = ({ mxEvent }) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
if (mxEvent.getThread() && !mxEvent.isThreadRoot) {
|
const thread = mxEvent.getThread();
|
||||||
|
if (thread?.rootEvent && !mxEvent.isThreadRoot) {
|
||||||
defaultDispatcher.dispatch<ShowThreadPayload>({
|
defaultDispatcher.dispatch<ShowThreadPayload>({
|
||||||
action: Action.ShowThread,
|
action: Action.ShowThread,
|
||||||
rootEvent: mxEvent.getThread()!.rootEvent,
|
rootEvent: thread.rootEvent,
|
||||||
initialEvent: mxEvent,
|
initialEvent: mxEvent,
|
||||||
scroll_into_view: true,
|
scroll_into_view: true,
|
||||||
highlighted: true,
|
highlighted: true,
|
||||||
|
|
|
@ -576,6 +576,12 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
|
||||||
|
|
||||||
const encryptionInfo = MatrixClientPeg.get().getEventEncryptionInfo(mxEvent);
|
const encryptionInfo = MatrixClientPeg.get().getEventEncryptionInfo(mxEvent);
|
||||||
const senderId = mxEvent.getSender();
|
const senderId = mxEvent.getSender();
|
||||||
|
if (!senderId) {
|
||||||
|
// something definitely wrong is going on here
|
||||||
|
this.setState({ verified: E2EState.Warning });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const userTrust = MatrixClientPeg.get().checkUserTrust(senderId);
|
const userTrust = MatrixClientPeg.get().checkUserTrust(senderId);
|
||||||
|
|
||||||
if (encryptionInfo.mismatchedSender) {
|
if (encryptionInfo.mismatchedSender) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ const SpacePublicShare: React.FC<IProps> = ({ space, onFinished }) => {
|
||||||
{_t("Share invite link")}
|
{_t("Share invite link")}
|
||||||
<span>{copiedText}</span>
|
<span>{copiedText}</span>
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
{space.canInvite(MatrixClientPeg.get()?.getUserId()) && shouldShowComponent(UIComponent.InviteUsers) ? (
|
{space.canInvite(MatrixClientPeg.get()?.getSafeUserId()) && shouldShowComponent(UIComponent.InviteUsers) ? (
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
className="mx_SpacePublicShare_inviteButton"
|
className="mx_SpacePublicShare_inviteButton"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
@ -23,11 +23,13 @@ import { PROPERTY_UPDATED } from "../stores/local-echo/GenericEchoChamber";
|
||||||
import { CachedRoomKey } from "../stores/local-echo/RoomEchoChamber";
|
import { CachedRoomKey } from "../stores/local-echo/RoomEchoChamber";
|
||||||
import { useEventEmitter } from "./useEventEmitter";
|
import { useEventEmitter } from "./useEventEmitter";
|
||||||
|
|
||||||
export const useNotificationState = (room: Room): [RoomNotifState, (state: RoomNotifState) => void] => {
|
export const useNotificationState = (room: Room): [RoomNotifState | undefined, (state: RoomNotifState) => void] => {
|
||||||
const echoChamber = useMemo(() => EchoChamber.forRoom(room), [room]);
|
const echoChamber = useMemo(() => EchoChamber.forRoom(room), [room]);
|
||||||
const [notificationState, setNotificationState] = useState<RoomNotifState>(echoChamber.notificationVolume);
|
const [notificationState, setNotificationState] = useState<RoomNotifState | undefined>(
|
||||||
|
echoChamber.notificationVolume,
|
||||||
|
);
|
||||||
useEventEmitter(echoChamber, PROPERTY_UPDATED, (key: CachedRoomKey) => {
|
useEventEmitter(echoChamber, PROPERTY_UPDATED, (key: CachedRoomKey) => {
|
||||||
if (key === CachedRoomKey.NotificationVolume) {
|
if (key === CachedRoomKey.NotificationVolume && echoChamber.notificationVolume !== undefined) {
|
||||||
setNotificationState(echoChamber.notificationVolume);
|
setNotificationState(echoChamber.notificationVolume);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -191,12 +191,12 @@ export const options: Opts = {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
|
||||||
formatHref: function (href: string, type: Type | string): string | null {
|
formatHref: function (href: string, type: Type | string): string {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type.RoomAlias:
|
case Type.RoomAlias:
|
||||||
case Type.UserId:
|
case Type.UserId:
|
||||||
default: {
|
default: {
|
||||||
return tryTransformEntityToPermalink(href);
|
return tryTransformEntityToPermalink(href) ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -209,7 +209,7 @@ export const options: Opts = {
|
||||||
|
|
||||||
className: "linkified",
|
className: "linkified",
|
||||||
|
|
||||||
target: function (href: string, type: Type | string): string | null {
|
target: function (href: string, type: Type | string): string {
|
||||||
if (type === Type.URL) {
|
if (type === Type.URL) {
|
||||||
try {
|
try {
|
||||||
const transformed = tryTransformPermalinkToLocalHref(href);
|
const transformed = tryTransformPermalinkToLocalHref(href);
|
||||||
|
@ -217,7 +217,7 @@ export const options: Opts = {
|
||||||
transformed !== href || // if it could be converted to handle locally for matrix symbols e.g. @user:server.tdl and matrix.to
|
transformed !== href || // if it could be converted to handle locally for matrix symbols e.g. @user:server.tdl and matrix.to
|
||||||
decodeURIComponent(href).match(ELEMENT_URL_PATTERN) // for https links to Element domains
|
decodeURIComponent(href).match(ELEMENT_URL_PATTERN) // for https links to Element domains
|
||||||
) {
|
) {
|
||||||
return null;
|
return "";
|
||||||
} else {
|
} else {
|
||||||
return "_blank";
|
return "_blank";
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ export const options: Opts = {
|
||||||
// malformed URI
|
// malformed URI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return "";
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ export class ProxiedModuleApi implements ModuleApi {
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
public getConfigValue<T>(namespace: string, key: string): T {
|
public getConfigValue<T>(namespace: string, key: string): T | undefined {
|
||||||
// Force cast to `any` because the namespace won't be known to the SdkConfig types
|
// Force cast to `any` because the namespace won't be known to the SdkConfig types
|
||||||
const maybeObj = SdkConfig.get(namespace as any);
|
const maybeObj = SdkConfig.get(namespace as any);
|
||||||
if (!maybeObj || !(typeof maybeObj === "object")) return undefined;
|
if (!maybeObj || !(typeof maybeObj === "object")) return undefined;
|
||||||
|
|
|
@ -47,7 +47,7 @@ export class PushRuleVectorState {
|
||||||
*
|
*
|
||||||
* @return [object] list of push-rule actions
|
* @return [object] list of push-rule actions
|
||||||
*/
|
*/
|
||||||
public static actionsFor(pushRuleVectorState: VectorState): PushRuleAction[] {
|
public static actionsFor(pushRuleVectorState?: VectorState): PushRuleAction[] {
|
||||||
if (pushRuleVectorState === VectorState.On) {
|
if (pushRuleVectorState === VectorState.On) {
|
||||||
return StandardActions.ACTION_NOTIFY;
|
return StandardActions.ACTION_NOTIFY;
|
||||||
} else if (pushRuleVectorState === VectorState.Loud) {
|
} else if (pushRuleVectorState === VectorState.Loud) {
|
||||||
|
|
|
@ -77,12 +77,11 @@ export function formatCryptoKey(key: string): string {
|
||||||
*/
|
*/
|
||||||
export function hashCode(str: string): number {
|
export function hashCode(str: string): number {
|
||||||
let hash = 0;
|
let hash = 0;
|
||||||
let i;
|
let chr: number;
|
||||||
let chr;
|
|
||||||
if (str.length === 0) {
|
if (str.length === 0) {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
for (i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
chr = str.charCodeAt(i);
|
chr = str.charCodeAt(i);
|
||||||
hash = (hash << 5) - hash + chr;
|
hash = (hash << 5) - hash + chr;
|
||||||
hash |= 0;
|
hash |= 0;
|
||||||
|
|
|
@ -1595,10 +1595,10 @@
|
||||||
version "3.2.14"
|
version "3.2.14"
|
||||||
resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz#acd96c00a881d0f462e1f97a56c73742c8dbc984"
|
resolved "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz#acd96c00a881d0f462e1f97a56c73742c8dbc984"
|
||||||
|
|
||||||
"@matrix-org/react-sdk-module-api@^0.0.4":
|
"@matrix-org/react-sdk-module-api@^0.0.5":
|
||||||
version "0.0.4"
|
version "0.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/@matrix-org/react-sdk-module-api/-/react-sdk-module-api-0.0.4.tgz#da71fc2e4c8143e87b5c2bc067ccbc0c146816fe"
|
resolved "https://registry.yarnpkg.com/@matrix-org/react-sdk-module-api/-/react-sdk-module-api-0.0.5.tgz#78bd80f42b918394978965ef3e08496e97948c7a"
|
||||||
integrity sha512-4gcgef3Ne9+Ae0bAErK1Swo9FxTZBDEogX/Iu2kcLWWROOKMjmeWL2PkM83ylsxZ32YY6a6ndRqV/SwRmDeJxg==
|
integrity sha512-QhH1T1E6Q6csCUitQzm32SRnX49Ox73TF5BZ4p5TOGFpPD3QuYc5/dDC1Yh3xUljgqOS2C6H24qaskw6olCtfQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.17.9"
|
"@babel/runtime" "^7.17.9"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue