mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
Fix react context not being assigned during construction
This commit is contained in:
parent
0a5abb09f4
commit
3a80df4222
@ -121,14 +121,15 @@ interface IState {
|
||||
@replaceableComponent("views.rooms.EditMessageComposer")
|
||||
export default class EditMessageComposer extends React.Component<IProps, IState> {
|
||||
static contextType = MatrixClientContext;
|
||||
context: React.ContextType<typeof MatrixClientContext>;
|
||||
context!: React.ContextType<typeof MatrixClientContext>;
|
||||
|
||||
private readonly editorRef = createRef<BasicMessageComposer>();
|
||||
private readonly dispatcherRef: string;
|
||||
private model: EditorModel = null;
|
||||
|
||||
constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||
super(props, context);
|
||||
super(props);
|
||||
this.context = context; // otherwise React will only set it prior to render due to type def above
|
||||
|
||||
this.state = {
|
||||
saveDisabled: true,
|
||||
|
@ -136,7 +136,7 @@ interface IProps {
|
||||
@replaceableComponent("views.rooms.SendMessageComposer")
|
||||
export default class SendMessageComposer extends React.Component<IProps> {
|
||||
static contextType = MatrixClientContext;
|
||||
context: React.ContextType<typeof MatrixClientContext>;
|
||||
context!: React.ContextType<typeof MatrixClientContext>;
|
||||
|
||||
private readonly prepareToEncrypt?: RateLimitedFunc;
|
||||
private readonly editorRef = createRef<BasicMessageComposer>();
|
||||
@ -146,8 +146,9 @@ export default class SendMessageComposer extends React.Component<IProps> {
|
||||
private sendHistoryManager: SendHistoryManager;
|
||||
|
||||
constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
|
||||
super(props, context);
|
||||
if (context.isCryptoEnabled() && context.isRoomEncrypted(this.props.room.roomId)) {
|
||||
super(props);
|
||||
this.context = context; // otherwise React will only set it prior to render due to type def above
|
||||
if (this.context.isCryptoEnabled() && this.context.isRoomEncrypted(this.props.room.roomId)) {
|
||||
this.prepareToEncrypt = new RateLimitedFunc(() => {
|
||||
this.context.prepareToEncrypt(this.props.room);
|
||||
}, 60000);
|
||||
|
Loading…
Reference in New Issue
Block a user