Fix React contexts (#12855)

This commit is contained in:
Michael Telatynski 2024-08-01 13:01:05 +01:00 committed by GitHub
parent 9b77279b3e
commit b6addb4118
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 99 additions and 107 deletions

View file

@ -56,9 +56,10 @@ export default class Autocomplete extends React.PureComponent<IProps, IState> {
private containerRef = createRef<HTMLDivElement>();
public static contextType = RoomContext;
public context!: React.ContextType<typeof RoomContext>;
public constructor(props: IProps) {
super(props);
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
super(props, context);
this.state = {
// list of completionResults, each containing completions

View file

@ -137,7 +137,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
private model!: EditorModel;
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
const isRestored = this.createEditorModel();

View file

@ -497,7 +497,7 @@ export default class RoomHeader extends React.Component<IProps, IState> {
private readonly client = this.props.room.client;
private readonly featureAskToJoinWatcher: string;
public constructor(props: IProps, context: IState) {
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
super(props, context);
const notiStore = RoomNotificationStateStore.instance.getRoomState(props.room);
notiStore.on(NotificationStateEvents.Update, this.onNotificationUpdate);

View file

@ -86,7 +86,7 @@ export default class MemberList extends React.Component<IProps, IState> {
private tiles: Map<string, MemberTile> = new Map();
public constructor(props: IProps, context: React.ContextType<typeof SDKContext>) {
super(props);
super(props, context);
this.state = this.getMembersState([], []);
this.showPresence = context?.memberListStore.isPresenceEnabled() ?? true;
this.mounted = true;

View file

@ -127,8 +127,8 @@ export class MessageComposer extends React.Component<IProps, IState> {
isRichTextEnabled: true,
};
public constructor(props: IProps) {
super(props);
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
super(props, context);
VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate);
this.state = {

View file

@ -39,6 +39,7 @@ interface IProps {
export default class ReplyPreview extends React.Component<IProps> {
public static contextType = RoomContext;
public context!: React.ContextType<typeof RoomContext>;
public render(): JSX.Element | null {
if (!this.props.replyToEvent) return null;

View file

@ -434,8 +434,8 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
public static contextType = MatrixClientContext;
public context!: React.ContextType<typeof MatrixClientContext>;
public constructor(props: IProps) {
super(props);
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
super(props, context);
this.state = {
sublists: {},

View file

@ -66,8 +66,8 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
public context!: React.ContextType<typeof RoomContext>;
private voiceRecordingId: string;
public constructor(props: IProps) {
super(props);
public constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
super(props, context);
this.state = {};