Avoid legacy contexts as much as possible (#29537)
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -40,8 +40,8 @@ export default class EmbeddedPage extends React.PureComponent<IProps, IState> {
|
|||||||
private unmounted = false;
|
private unmounted = false;
|
||||||
private dispatcherRef?: string;
|
private dispatcherRef?: string;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
page: "",
|
page: "",
|
||||||
|
|||||||
@@ -259,8 +259,8 @@ export default class MessagePanel extends React.Component<IProps, IState> {
|
|||||||
// A map to allow groupers to maintain consistent keys even if their first event is uprooted due to back-pagination.
|
// A map to allow groupers to maintain consistent keys even if their first event is uprooted due to back-pagination.
|
||||||
public grouperKeyMap = new WeakMap<MatrixEvent, string>();
|
public grouperKeyMap = new WeakMap<MatrixEvent, string>();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
// previous positions the read marker has been in, so we can
|
// previous positions the read marker has been in, so we can
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export default class NotificationPanel extends React.PureComponent<IProps, IStat
|
|||||||
|
|
||||||
private card = React.createRef<HTMLDivElement>();
|
private card = React.createRef<HTMLDivElement>();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
narrow: false,
|
narrow: false,
|
||||||
|
|||||||
@@ -64,10 +64,6 @@ export default class RightPanel extends React.Component<Props, IState> {
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: Props, context: React.ContextType<typeof MatrixClientContext>) {
|
|
||||||
super(props, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly delayedUpdate = throttle(
|
private readonly delayedUpdate = throttle(
|
||||||
(): void => {
|
(): void => {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
|||||||
@@ -86,8 +86,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, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||||||
private readonly dndWatcherRef?: string;
|
private readonly dndWatcherRef?: string;
|
||||||
private buttonRef: React.RefObject<HTMLButtonElement> = createRef();
|
private buttonRef: React.RefObject<HTMLButtonElement> = createRef();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
contextMenuPosition: null,
|
contextMenuPosition: null,
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ export default class UserView extends React.Component<IProps, IState> {
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||||||
public static contextType = SDKContext;
|
public static contextType = SDKContext;
|
||||||
declare public context: React.ContextType<typeof SDKContext>;
|
declare public context: React.ContextType<typeof SDKContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
loginView: LoginView.Loading,
|
loginView: LoginView.Loading,
|
||||||
|
|||||||
@@ -130,8 +130,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, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
canRedact: false,
|
canRedact: false,
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ export default class ReplyChain extends React.Component<IProps, IState> {
|
|||||||
private room: Room;
|
private room: Room;
|
||||||
private blockquoteRef = React.createRef<HTMLQuoteElement>();
|
private blockquoteRef = React.createRef<HTMLQuoteElement>();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
events: [],
|
events: [],
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
|
|||||||
|
|
||||||
private fieldRef = createRef<Field>();
|
private fieldRef = createRef<Field>();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isValid: true,
|
isValid: true,
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class ReactionPicker extends React.Component<IProps, IState> {
|
|||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
declare public context: React.ContextType<typeof RoomContext>;
|
declare public context: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedEmojis: new Set(Object.keys(this.getReactions())),
|
selectedEmojis: new Set(Object.keys(this.getReactions())),
|
||||||
|
|||||||
@@ -47,8 +47,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, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: ILocationPickerProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
position: undefined,
|
position: undefined,
|
||||||
|
|||||||
@@ -36,8 +36,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, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IBodyProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ export default class MPollBody extends React.Component<IBodyProps, IState> {
|
|||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare 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, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IBodyProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
selected: null,
|
selected: null,
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import UnknownBody from "./UnknownBody";
|
|||||||
import { type IMediaBody } from "./IMediaBody";
|
import { type IMediaBody } from "./IMediaBody";
|
||||||
import { MediaEventHelper } from "../../../utils/MediaEventHelper";
|
import { MediaEventHelper } from "../../../utils/MediaEventHelper";
|
||||||
import { type IBodyProps } from "./IBodyProps";
|
import { type IBodyProps } from "./IBodyProps";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
|
||||||
import TextualBody from "./TextualBody";
|
import TextualBody from "./TextualBody";
|
||||||
import MImageBody from "./MImageBody";
|
import MImageBody from "./MImageBody";
|
||||||
import MFileBody from "./MFileBody";
|
import MFileBody from "./MFileBody";
|
||||||
@@ -83,11 +82,8 @@ export default class MessageEvent extends React.Component<IProps> implements IMe
|
|||||||
private bodyTypes = new Map<string, React.ComponentType<IBodyProps>>(baseBodyTypes.entries());
|
private bodyTypes = new Map<string, React.ComponentType<IBodyProps>>(baseBodyTypes.entries());
|
||||||
private evTypes = new Map<string, React.ComponentType<IBodyProps>>(baseEvTypes.entries());
|
private evTypes = new Map<string, React.ComponentType<IBodyProps>>(baseEvTypes.entries());
|
||||||
|
|
||||||
public static contextType = MatrixClientContext;
|
public constructor(props: IProps) {
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
super(props);
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
|
||||||
super(props, context);
|
|
||||||
|
|
||||||
if (MediaEventHelper.isEligible(this.props.mxEvent)) {
|
if (MediaEventHelper.isEligible(this.props.mxEvent)) {
|
||||||
this.mediaHelper = new MediaEventHelper(this.props.mxEvent);
|
this.mediaHelper = new MediaEventHelper(this.props.mxEvent);
|
||||||
|
|||||||
@@ -77,8 +77,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, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
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"),
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ export default class AliasSettings extends React.Component<IProps, IState> {
|
|||||||
canSetCanonicalAlias: false,
|
canSetCanonicalAlias: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
public constructor(props: IProps, context: ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
const state: IState = {
|
const state: IState = {
|
||||||
altAliases: [],
|
altAliases: [],
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ export default class Autocomplete extends React.PureComponent<IProps, IState> {
|
|||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
declare public context: React.ContextType<typeof RoomContext>;
|
declare public context: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
// list of completionResults, each containing completions
|
// list of completionResults, each containing completions
|
||||||
|
|||||||
@@ -437,8 +437,8 @@ export default class LegacyRoomList extends React.PureComponent<IProps, IState>
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
sublists: {},
|
sublists: {},
|
||||||
|
|||||||
@@ -124,9 +124,8 @@ export class MessageComposer extends React.Component<IProps, IState> {
|
|||||||
isRichTextEnabled: true,
|
isRichTextEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
this.context = context; // otherwise React will only set it prior to render due to type def above
|
|
||||||
|
|
||||||
const isWysiwygLabEnabled = SettingsStore.getValue("feature_wysiwyg_composer");
|
const isWysiwygLabEnabled = SettingsStore.getValue("feature_wysiwyg_composer");
|
||||||
let isRichTextEnabled = true;
|
let isRichTextEnabled = true;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export default class RoomUpgradeWarningBar extends React.PureComponent<IProps, I
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
const tombstone = this.props.room.currentState.getStateEvents("m.room.tombstone", "");
|
const tombstone = this.props.room.currentState.getStateEvents("m.room.tombstone", "");
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ export default class SearchResultTile extends React.Component<IProps> {
|
|||||||
// A map of <callId, LegacyCallEventGrouper>
|
// A map of <callId, LegacyCallEventGrouper>
|
||||||
private callEventGroupers = new Map<string, LegacyCallEventGrouper>();
|
private callEventGroupers = new Map<string, LegacyCallEventGrouper>();
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.buildLegacyCallEventGroupers(this.props.timeline);
|
this.buildLegacyCallEventGroupers(this.props.timeline);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
|||||||
declare public context: React.ContextType<typeof RoomContext>;
|
declare public context: React.ContextType<typeof RoomContext>;
|
||||||
private voiceRecordingId: string;
|
private voiceRecordingId: string;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {};
|
this.state = {};
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ export default class GeneralRoomSettingsTab extends React.Component<IProps, ISta
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: ContextType<typeof MatrixClientContext>;
|
declare public context: ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isRoomPublished: false, // loaded async
|
isRoomPublished: false, // loaded async
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: IProps) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
const state = this.props.room.currentState;
|
const state = this.props.room.currentState;
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ export default class HelpUserSettingsTab extends React.Component<EmptyObject, IS
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: EmptyObject, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: EmptyObject) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
appVersion: null,
|
appVersion: null,
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ export default class VoiceUserSettingsTab extends React.Component<EmptyObject, I
|
|||||||
public static contextType = MatrixClientContext;
|
public static contextType = MatrixClientContext;
|
||||||
declare public context: React.ContextType<typeof MatrixClientContext>;
|
declare public context: React.ContextType<typeof MatrixClientContext>;
|
||||||
|
|
||||||
public constructor(props: EmptyObject, context: React.ContextType<typeof MatrixClientContext>) {
|
public constructor(props: EmptyObject) {
|
||||||
super(props, context);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
mediaDevices: null,
|
mediaDevices: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user