StickerPicker: update when accountdata is updated (#10945)

* StickerPicker: update when accountdata is updated

This was incorrectly listening for in-room account data; in fact `m.widgets` is
global account data.

Fixes some flaky cypress tests.

* another ref
t3chguy/dedup-icons-17oct
Richard van der Hoff 2023-05-19 10:52:17 +01:00 committed by GitHub
parent 8513d2f4ff
commit 606eaa5274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -15,9 +15,10 @@ limitations under the License.
*/ */
import React from "react"; import React from "react";
import { Room, RoomEvent } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { IWidget } from "matrix-widget-api"; import { IWidget } from "matrix-widget-api";
import { ClientEvent } from "matrix-js-sdk/src/client";
import { _t, _td } from "../../../languageHandler"; import { _t, _td } from "../../../languageHandler";
import AppTile from "../elements/AppTile"; import AppTile from "../elements/AppTile";
@ -138,7 +139,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
// Track updates to widget state in account data // Track updates to widget state in account data
MatrixClientPeg.get().on(RoomEvent.AccountData, this.updateWidget); MatrixClientPeg.get().on(ClientEvent.AccountData, this.updateWidget);
RightPanelStore.instance.on(UPDATE_EVENT, this.onRightPanelStoreUpdate); RightPanelStore.instance.on(UPDATE_EVENT, this.onRightPanelStoreUpdate);
// Initialise widget state from current account data // Initialise widget state from current account data
@ -147,7 +148,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
public componentWillUnmount(): void { public componentWillUnmount(): void {
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
if (client) client.removeListener(RoomEvent.AccountData, this.updateWidget); if (client) client.removeListener(ClientEvent.AccountData, this.updateWidget);
RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate); RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate);
window.removeEventListener("resize", this.onResize); window.removeEventListener("resize", this.onResize);
if (this.dispatcherRef) { if (this.dispatcherRef) {