From 606eaa5274fd3cd81af01981c81d71cfce14831c Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 19 May 2023 10:52:17 +0100 Subject: [PATCH] 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 --- src/components/views/rooms/Stickerpicker.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/Stickerpicker.tsx b/src/components/views/rooms/Stickerpicker.tsx index 92b7ddd6509..8b23c6a0cf6 100644 --- a/src/components/views/rooms/Stickerpicker.tsx +++ b/src/components/views/rooms/Stickerpicker.tsx @@ -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 { 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 { 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) {