Fix React contexts (#12855)
This commit is contained in:
parent
9b77279b3e
commit
b6addb4118
35 changed files with 99 additions and 107 deletions
|
@ -45,10 +45,11 @@ interface IState {
|
||||||
|
|
||||||
export default class EmbeddedPage extends React.PureComponent<IProps, IState> {
|
export default class EmbeddedPage extends React.PureComponent<IProps, IState> {
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
private unmounted = false;
|
private unmounted = false;
|
||||||
private dispatcherRef: string | null = null;
|
private dispatcherRef: string | null = null;
|
||||||
|
|
||||||
public constructor(props: IProps, context: typeof MatrixClientContext) {
|
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -59,6 +59,7 @@ interface IState {
|
||||||
*/
|
*/
|
||||||
class FilePanel extends React.Component<IProps, IState> {
|
class FilePanel extends React.Component<IProps, IState> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
// This is used to track if a decrypted event was a live event and should be
|
// This is used to track if a decrypted event was a live event and should be
|
||||||
// added to the timeline.
|
// added to the timeline.
|
||||||
|
|
|
@ -42,11 +42,12 @@ interface IState {
|
||||||
*/
|
*/
|
||||||
export default class NotificationPanel extends React.PureComponent<IProps, IState> {
|
export default class NotificationPanel extends React.PureComponent<IProps, IState> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
private card = React.createRef<HTMLDivElement>();
|
private card = React.createRef<HTMLDivElement>();
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
narrow: false,
|
narrow: false,
|
||||||
|
|
|
@ -15,7 +15,16 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ReactNode } from "react";
|
import React, { ReactNode } from "react";
|
||||||
import { EventStatus, MatrixEvent, Room, MatrixError, SyncState, SyncStateData } from "matrix-js-sdk/src/matrix";
|
import {
|
||||||
|
ClientEvent,
|
||||||
|
EventStatus,
|
||||||
|
MatrixError,
|
||||||
|
MatrixEvent,
|
||||||
|
Room,
|
||||||
|
RoomEvent,
|
||||||
|
SyncState,
|
||||||
|
SyncStateData,
|
||||||
|
} from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import { Icon as WarningIcon } from "../../../res/img/feather-customised/warning-triangle.svg";
|
import { Icon as WarningIcon } from "../../../res/img/feather-customised/warning-triangle.svg";
|
||||||
import { _t, _td } from "../../languageHandler";
|
import { _t, _td } from "../../languageHandler";
|
||||||
|
@ -79,8 +88,8 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
syncState: SyncState;
|
syncState: SyncState | null;
|
||||||
syncStateData: SyncStateData;
|
syncStateData: SyncStateData | null;
|
||||||
unsentMessages: MatrixEvent[];
|
unsentMessages: MatrixEvent[];
|
||||||
isResending: boolean;
|
isResending: boolean;
|
||||||
}
|
}
|
||||||
|
@ -88,9 +97,11 @@ interface IState {
|
||||||
export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
|
export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
|
||||||
private unmounted = false;
|
private unmounted = false;
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: typeof MatrixClientContext) {
|
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
this.context = context; // XXX: workaround for lack of `declare` support on `public context!:` definition
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
syncState: this.context.getSyncState(),
|
syncState: this.context.getSyncState(),
|
||||||
|
@ -102,8 +113,8 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
|
||||||
|
|
||||||
public componentDidMount(): void {
|
public componentDidMount(): void {
|
||||||
const client = this.context;
|
const client = this.context;
|
||||||
client.on("sync", this.onSyncStateChange);
|
client.on(ClientEvent.Sync, this.onSyncStateChange);
|
||||||
client.on("Room.localEchoUpdated", this.onRoomLocalEchoUpdated);
|
client.on(RoomEvent.LocalEchoUpdated, this.onRoomLocalEchoUpdated);
|
||||||
|
|
||||||
this.checkSize();
|
this.checkSize();
|
||||||
}
|
}
|
||||||
|
@ -117,19 +128,19 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
|
||||||
// we may have entirely lost our client as we're logging out before clicking login on the guest bar...
|
// we may have entirely lost our client as we're logging out before clicking login on the guest bar...
|
||||||
const client = this.context;
|
const client = this.context;
|
||||||
if (client) {
|
if (client) {
|
||||||
client.removeListener("sync", this.onSyncStateChange);
|
client.removeListener(ClientEvent.Sync, this.onSyncStateChange);
|
||||||
client.removeListener("Room.localEchoUpdated", this.onRoomLocalEchoUpdated);
|
client.removeListener(RoomEvent.LocalEchoUpdated, this.onRoomLocalEchoUpdated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onSyncStateChange = (state: SyncState, prevState: SyncState, data: SyncStateData): void => {
|
private onSyncStateChange = (state: SyncState, prevState: SyncState | null, data?: SyncStateData): void => {
|
||||||
if (state === "SYNCING" && prevState === "SYNCING") {
|
if (state === "SYNCING" && prevState === "SYNCING") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.unmounted) return;
|
if (this.unmounted) return;
|
||||||
this.setState({
|
this.setState({
|
||||||
syncState: state,
|
syncState: state,
|
||||||
syncStateData: data,
|
syncStateData: data ?? null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ export default class ThreadView extends React.Component<IProps, IState> {
|
||||||
// Set by setEventId in ctor.
|
// Set by setEventId in ctor.
|
||||||
private eventId!: string;
|
private eventId!: string;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.setEventId(this.props.mxEvent);
|
this.setEventId(this.props.mxEvent);
|
||||||
const thread = this.props.room.getThread(this.eventId) ?? undefined;
|
const thread = this.props.room.getThread(this.eventId) ?? undefined;
|
||||||
|
|
|
@ -43,8 +43,8 @@ export default class UserView extends React.Component<IProps, IState> {
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,8 +137,8 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
||||||
|
|
||||||
private reactButtonRef = createRef<any>(); // XXX Ref to a functional component
|
private reactButtonRef = createRef<any>(); // XXX Ref to a functional component
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
canRedact: false,
|
canRedact: false,
|
||||||
|
|
|
@ -143,7 +143,7 @@ export default class AppTile extends React.Component<IProps, IState> {
|
||||||
private unmounted = false;
|
private unmounted = false;
|
||||||
|
|
||||||
public constructor(props: IProps, context: ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps, context: ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.context = context; // XXX: workaround for lack of `declare` support on `public context!:` definition
|
this.context = context; // XXX: workaround for lack of `declare` support on `public context!:` definition
|
||||||
|
|
||||||
// Tiles in miniMode are floating, and therefore not docked
|
// Tiles in miniMode are floating, and therefore not docked
|
||||||
|
|
|
@ -55,8 +55,8 @@ class LocationPicker extends React.Component<ILocationPickerProps, IState> {
|
||||||
private geolocate?: maplibregl.GeolocateControl;
|
private geolocate?: maplibregl.GeolocateControl;
|
||||||
private marker?: maplibregl.Marker;
|
private marker?: maplibregl.Marker;
|
||||||
|
|
||||||
public constructor(props: ILocationPickerProps) {
|
public constructor(props: ILocationPickerProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
position: undefined,
|
position: undefined,
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
|
||||||
private tooltips: Element[] = [];
|
private tooltips: Element[] = [];
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
const cli = this.context;
|
const cli = this.context;
|
||||||
|
|
|
@ -40,11 +40,7 @@ export default class MAudioBody extends React.PureComponent<IBodyProps, IState>
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
public context!: React.ContextType<typeof RoomContext>;
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public constructor(props: IBodyProps) {
|
public state: IState = {};
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async componentDidMount(): Promise<void> {
|
public async componentDidMount(): Promise<void> {
|
||||||
let buffer: ArrayBuffer;
|
let buffer: ArrayBuffer;
|
||||||
|
|
|
@ -108,6 +108,8 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
public context!: React.ContextType<typeof RoomContext>;
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
|
public state: IState = {};
|
||||||
|
|
||||||
public static defaultProps = {
|
public static defaultProps = {
|
||||||
showGenericPlaceholder: true,
|
showGenericPlaceholder: true,
|
||||||
};
|
};
|
||||||
|
@ -117,12 +119,6 @@ export default class MFileBody extends React.Component<IProps, IState> {
|
||||||
private userDidClick = false;
|
private userDidClick = false;
|
||||||
private fileDownloader: FileDownloader = new FileDownloader(() => this.iframe.current);
|
private fileDownloader: FileDownloader = new FileDownloader(() => this.iframe.current);
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
private getContentUrl(): string | null {
|
private getContentUrl(): string | null {
|
||||||
if (this.props.forExport) return null;
|
if (this.props.forExport) return null;
|
||||||
const media = mediaFromContent(this.props.mxEvent.getContent());
|
const media = mediaFromContent(this.props.mxEvent.getContent());
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { Blurhash } from "react-blurhash";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { CSSTransition, SwitchTransition } from "react-transition-group";
|
import { CSSTransition, SwitchTransition } from "react-transition-group";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { ClientEvent, ClientEventHandlerMap } from "matrix-js-sdk/src/matrix";
|
import { ClientEvent } from "matrix-js-sdk/src/matrix";
|
||||||
import { ImageContent } from "matrix-js-sdk/src/types";
|
import { ImageContent } from "matrix-js-sdk/src/types";
|
||||||
import { Tooltip } from "@vector-im/compound-web";
|
import { Tooltip } from "@vector-im/compound-web";
|
||||||
|
|
||||||
|
@ -71,14 +71,8 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
private image = createRef<HTMLImageElement>();
|
private image = createRef<HTMLImageElement>();
|
||||||
private timeout?: number;
|
private timeout?: number;
|
||||||
private sizeWatcher?: string;
|
private sizeWatcher?: string;
|
||||||
private reconnectedListener: ClientEventHandlerMap[ClientEvent.Sync];
|
|
||||||
|
|
||||||
public constructor(props: IBodyProps) {
|
public state: IState = {
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.reconnectedListener = createReconnectedListener(this.clearError);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
contentUrl: null,
|
contentUrl: null,
|
||||||
thumbUrl: null,
|
thumbUrl: null,
|
||||||
imgError: false,
|
imgError: false,
|
||||||
|
@ -87,7 +81,6 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
showImage: SettingsStore.getValue("showImages"),
|
showImage: SettingsStore.getValue("showImages"),
|
||||||
placeholder: Placeholder.NoImage,
|
placeholder: Placeholder.NoImage,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
protected showImage(): void {
|
protected showImage(): void {
|
||||||
localStorage.setItem("mx_ShowImage_" + this.props.mxEvent.getId(), "true");
|
localStorage.setItem("mx_ShowImage_" + this.props.mxEvent.getId(), "true");
|
||||||
|
@ -160,10 +153,10 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
|
||||||
imgElement.src = url;
|
imgElement.src = url;
|
||||||
};
|
};
|
||||||
|
|
||||||
private clearError = (): void => {
|
private reconnectedListener = createReconnectedListener((): void => {
|
||||||
MatrixClientPeg.get()?.off(ClientEvent.Sync, this.reconnectedListener);
|
MatrixClientPeg.get()?.off(ClientEvent.Sync, this.reconnectedListener);
|
||||||
this.setState({ imgError: false });
|
this.setState({ imgError: false });
|
||||||
};
|
});
|
||||||
|
|
||||||
private onImageError = (): void => {
|
private onImageError = (): void => {
|
||||||
// If the thumbnail failed to load then try again using the contentUrl
|
// If the thumbnail failed to load then try again using the contentUrl
|
||||||
|
|
|
@ -44,8 +44,8 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
private mapId: string;
|
private mapId: string;
|
||||||
private reconnectedListener: ClientEventHandlerMap[ClientEvent.Sync];
|
private reconnectedListener: ClientEventHandlerMap[ClientEvent.Sync];
|
||||||
|
|
||||||
public constructor(props: IBodyProps) {
|
public constructor(props: IBodyProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
// multiple instances of same map might be in document
|
// multiple instances of same map might be in document
|
||||||
// eg thread and main timeline, reply
|
// eg thread and main timeline, reply
|
||||||
|
|
|
@ -150,8 +150,8 @@ export default class MPollBody extends React.Component<IBodyProps, IState> {
|
||||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
private seenEventIds: string[] = []; // Events we have already seen
|
private seenEventIds: string[] = []; // Events we have already seen
|
||||||
|
|
||||||
public constructor(props: IBodyProps) {
|
public constructor(props: IBodyProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
selected: null,
|
selected: null,
|
||||||
|
|
|
@ -47,10 +47,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
|
||||||
private videoRef = React.createRef<HTMLVideoElement>();
|
private videoRef = React.createRef<HTMLVideoElement>();
|
||||||
private sizeWatcher?: string;
|
private sizeWatcher?: string;
|
||||||
|
|
||||||
public constructor(props: IBodyProps) {
|
public state = {
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
fetchingData: false,
|
fetchingData: false,
|
||||||
decryptedUrl: null,
|
decryptedUrl: null,
|
||||||
decryptedThumbnailUrl: null,
|
decryptedThumbnailUrl: null,
|
||||||
|
@ -59,7 +56,6 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
|
||||||
posterLoading: false,
|
posterLoading: false,
|
||||||
blurhashUrl: null,
|
blurhashUrl: null,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
private getContentUrl(): string | undefined {
|
private getContentUrl(): string | undefined {
|
||||||
const content = this.props.mxEvent.getContent<MediaEventContent>();
|
const content = this.props.mxEvent.getContent<MediaEventContent>();
|
||||||
|
|
|
@ -261,6 +261,7 @@ interface IMessageActionBarProps {
|
||||||
|
|
||||||
export default class MessageActionBar extends React.PureComponent<IMessageActionBarProps> {
|
export default class MessageActionBar extends React.PureComponent<IMessageActionBarProps> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public componentDidMount(): void {
|
public componentDidMount(): void {
|
||||||
if (this.props.mxEvent.status && this.props.mxEvent.status !== EventStatus.SENT) {
|
if (this.props.mxEvent.status && this.props.mxEvent.status !== EventStatus.SENT) {
|
||||||
|
|
|
@ -68,14 +68,10 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
public context!: React.ContextType<typeof RoomContext>;
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public constructor(props: IBodyProps) {
|
public state = {
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
links: [],
|
links: [],
|
||||||
widgetHidden: false,
|
widgetHidden: false,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
public componentDidMount(): void {
|
public componentDidMount(): void {
|
||||||
if (!this.props.editState) {
|
if (!this.props.editState) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ interface IState {
|
||||||
|
|
||||||
export default class TimelineCard extends React.Component<IProps, IState> {
|
export default class TimelineCard extends React.Component<IProps, IState> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
private dispatcherRef?: string;
|
private dispatcherRef?: string;
|
||||||
private layoutWatcherRef?: string;
|
private layoutWatcherRef?: string;
|
||||||
|
@ -84,8 +85,8 @@ export default class TimelineCard extends React.Component<IProps, IState> {
|
||||||
private card = React.createRef<HTMLDivElement>();
|
private card = React.createRef<HTMLDivElement>();
|
||||||
private readReceiptsSettingWatcher: string | undefined;
|
private readReceiptsSettingWatcher: string | undefined;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
showReadReceipts: SettingsStore.getValue("showReadReceipts", props.room.roomId),
|
showReadReceipts: SettingsStore.getValue("showReadReceipts", props.room.roomId),
|
||||||
layout: SettingsStore.getValue("layout"),
|
layout: SettingsStore.getValue("layout"),
|
||||||
|
|
|
@ -56,9 +56,10 @@ export default class Autocomplete extends React.PureComponent<IProps, IState> {
|
||||||
private containerRef = createRef<HTMLDivElement>();
|
private containerRef = createRef<HTMLDivElement>();
|
||||||
|
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
// list of completionResults, each containing completions
|
// list of completionResults, each containing completions
|
||||||
|
|
|
@ -137,7 +137,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
|
||||||
private model!: EditorModel;
|
private model!: EditorModel;
|
||||||
|
|
||||||
public constructor(props: IEditMessageComposerProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IEditMessageComposerProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.context = context; // otherwise React will only set it prior to render due to type def above
|
this.context = context; // otherwise React will only set it prior to render due to type def above
|
||||||
|
|
||||||
const isRestored = this.createEditorModel();
|
const isRestored = this.createEditorModel();
|
||||||
|
|
|
@ -497,7 +497,7 @@ export default class RoomHeader extends React.Component<IProps, IState> {
|
||||||
private readonly client = this.props.room.client;
|
private readonly client = this.props.room.client;
|
||||||
private readonly featureAskToJoinWatcher: string;
|
private readonly featureAskToJoinWatcher: string;
|
||||||
|
|
||||||
public constructor(props: IProps, context: IState) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
const notiStore = RoomNotificationStateStore.instance.getRoomState(props.room);
|
const notiStore = RoomNotificationStateStore.instance.getRoomState(props.room);
|
||||||
notiStore.on(NotificationStateEvents.Update, this.onNotificationUpdate);
|
notiStore.on(NotificationStateEvents.Update, this.onNotificationUpdate);
|
||||||
|
|
|
@ -86,7 +86,7 @@ export default class MemberList extends React.Component<IProps, IState> {
|
||||||
private tiles: Map<string, MemberTile> = new Map();
|
private tiles: Map<string, MemberTile> = new Map();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
|
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.state = this.getMembersState([], []);
|
this.state = this.getMembersState([], []);
|
||||||
this.showPresence = context?.memberListStore.isPresenceEnabled() ?? true;
|
this.showPresence = context?.memberListStore.isPresenceEnabled() ?? true;
|
||||||
this.mounted = true;
|
this.mounted = true;
|
||||||
|
|
|
@ -127,8 +127,8 @@ export class MessageComposer extends React.Component<IProps, IState> {
|
||||||
isRichTextEnabled: true,
|
isRichTextEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate);
|
VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -39,6 +39,7 @@ interface IProps {
|
||||||
|
|
||||||
export default class ReplyPreview extends React.Component<IProps> {
|
export default class ReplyPreview extends React.Component<IProps> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public render(): JSX.Element | null {
|
public render(): JSX.Element | null {
|
||||||
if (!this.props.replyToEvent) return null;
|
if (!this.props.replyToEvent) return null;
|
||||||
|
|
|
@ -434,8 +434,8 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
sublists: {},
|
sublists: {},
|
||||||
|
|
|
@ -66,8 +66,8 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
||||||
public context!: React.ContextType<typeof RoomContext>;
|
public context!: React.ContextType<typeof RoomContext>;
|
||||||
private voiceRecordingId: string;
|
private voiceRecordingId: string;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {};
|
this.state = {};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
|
||||||
public context!: React.ContextType<typeof SDKContext>;
|
public context!: React.ContextType<typeof SDKContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
|
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -42,8 +42,8 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
appVersion: null,
|
appVersion: null,
|
||||||
|
|
|
@ -61,8 +61,8 @@ export default class VoiceUserSettingsTab extends React.Component<{}, IState> {
|
||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
public context!: React.ContextType<typeof MatrixClientContext>;
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: {}) {
|
public constructor(props: {}, context: React.ContextType<typeof MatrixClientContext>) {
|
||||||
super(props);
|
super(props, context);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
mediaDevices: null,
|
mediaDevices: null,
|
||||||
|
|
|
@ -38,7 +38,6 @@ import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||||
import { Action } from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
||||||
import { toRightOf, useContextMenu } from "../../structures/ContextMenu";
|
import { toRightOf, useContextMenu } from "../../structures/ContextMenu";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
|
||||||
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
|
||||||
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
||||||
import { NotificationLevel } from "../../../stores/notifications/NotificationLevel";
|
import { NotificationLevel } from "../../../stores/notifications/NotificationLevel";
|
||||||
|
@ -198,8 +197,6 @@ interface IItemState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
public static contextType = MatrixClientContext;
|
|
||||||
|
|
||||||
private buttonRef = createRef<HTMLDivElement>();
|
private buttonRef = createRef<HTMLDivElement>();
|
||||||
|
|
||||||
public constructor(props: IItemProps) {
|
public constructor(props: IItemProps) {
|
||||||
|
|
|
@ -535,7 +535,7 @@ function createRightClickMenu(mxEvent: MatrixEvent, context?: Partial<IRoomState
|
||||||
|
|
||||||
function createMenuWithContent(
|
function createMenuWithContent(
|
||||||
eventContent: object,
|
eventContent: object,
|
||||||
props?: Partial<React.ComponentProps<typeof MessageContextMenu>>,
|
props?: Partial<MessageContextMenu["props"]>,
|
||||||
context?: Partial<IRoomState>,
|
context?: Partial<IRoomState>,
|
||||||
): RenderResult {
|
): RenderResult {
|
||||||
// XXX: We probably shouldn't be assuming all events are going to be message events, but considering this
|
// XXX: We probably shouldn't be assuming all events are going to be message events, but considering this
|
||||||
|
@ -552,7 +552,7 @@ function makeDefaultRoom(): Room {
|
||||||
|
|
||||||
function createMenu(
|
function createMenu(
|
||||||
mxEvent: MatrixEvent,
|
mxEvent: MatrixEvent,
|
||||||
props?: Partial<React.ComponentProps<typeof MessageContextMenu>>,
|
props?: Partial<MessageContextMenu["props"]>,
|
||||||
context: Partial<IRoomState> = {},
|
context: Partial<IRoomState> = {},
|
||||||
beacons: Map<BeaconIdentifier, Beacon> = new Map(),
|
beacons: Map<BeaconIdentifier, Beacon> = new Map(),
|
||||||
room: Room = makeDefaultRoom(),
|
room: Room = makeDefaultRoom(),
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps } from "react";
|
import React from "react";
|
||||||
import { fireEvent, render, waitFor } from "@testing-library/react";
|
import { fireEvent, render, waitFor } from "@testing-library/react";
|
||||||
import { LocationAssetType, ClientEvent, RoomMember, SyncState } from "matrix-js-sdk/src/matrix";
|
import { LocationAssetType, ClientEvent, RoomMember, SyncState } from "matrix-js-sdk/src/matrix";
|
||||||
import * as maplibregl from "maplibre-gl";
|
import * as maplibregl from "maplibre-gl";
|
||||||
|
@ -42,7 +42,7 @@ describe("MLocationBody", () => {
|
||||||
isGuest: jest.fn().mockReturnValue(false),
|
isGuest: jest.fn().mockReturnValue(false),
|
||||||
});
|
});
|
||||||
const defaultEvent = makeLocationEvent("geo:51.5076,-0.1276", LocationAssetType.Pin);
|
const defaultEvent = makeLocationEvent("geo:51.5076,-0.1276", LocationAssetType.Pin);
|
||||||
const defaultProps: ComponentProps<typeof MLocationBody> = {
|
const defaultProps: MLocationBody["props"] = {
|
||||||
mxEvent: defaultEvent,
|
mxEvent: defaultEvent,
|
||||||
highlights: [],
|
highlights: [],
|
||||||
highlightLink: "",
|
highlightLink: "",
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps } from "react";
|
import React from "react";
|
||||||
import { EventType, getHttpUriForMxc, IContent, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
import { EventType, getHttpUriForMxc, IContent, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||||
import { render, RenderResult } from "@testing-library/react";
|
import { render, RenderResult } from "@testing-library/react";
|
||||||
import fetchMock from "fetch-mock-jest";
|
import fetchMock from "fetch-mock-jest";
|
||||||
|
@ -117,7 +117,7 @@ function makeMVideoBody(w: number, h: number): RenderResult {
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
|
|
||||||
const defaultProps: ComponentProps<typeof MVideoBody> = {
|
const defaultProps: MVideoBody["props"] = {
|
||||||
mxEvent: event,
|
mxEvent: event,
|
||||||
highlights: [],
|
highlights: [],
|
||||||
highlightLink: "",
|
highlightLink: "",
|
||||||
|
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentProps } from "react";
|
import React from "react";
|
||||||
import { cleanup, queryByRole, render, screen, within } from "@testing-library/react";
|
import { cleanup, queryByRole, render, screen, within } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
|
@ -53,7 +53,7 @@ describe("RoomList", () => {
|
||||||
const client = MatrixClientPeg.safeGet();
|
const client = MatrixClientPeg.safeGet();
|
||||||
const store = SpaceStore.instance;
|
const store = SpaceStore.instance;
|
||||||
|
|
||||||
function getComponent(props: Partial<ComponentProps<typeof RoomList>> = {}): JSX.Element {
|
function getComponent(props: Partial<RoomList["props"]> = {}): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<RoomList
|
<RoomList
|
||||||
onKeyDown={jest.fn()}
|
onKeyDown={jest.fn()}
|
||||||
|
|
Loading…
Reference in a new issue