Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
StickerPicker: update when accountdata is updated (#10945)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
richvdh committed May 19, 2023
1 parent 8513d2f commit 606eaa5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/views/rooms/Stickerpicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 606eaa5

Please sign in to comment.