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
This commit is contained in:
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

View File

@ -15,9 +15,10 @@ limitations under the License.
*/
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 { IWidget } from "matrix-widget-api";
import { ClientEvent } from "matrix-js-sdk/src/client";
import { _t, _td } from "../../../languageHandler";
import AppTile from "../elements/AppTile";
@ -138,7 +139,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
this.dispatcherRef = dis.register(this.onAction);
// 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);
// Initialise widget state from current account data
@ -147,7 +148,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
public componentWillUnmount(): void {
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);
window.removeEventListener("resize", this.onResize);
if (this.dispatcherRef) {