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

Commit da2471f

Browse files
Fix a crash when removing persistent widgets (updated) (#10099)
* Fix a crash when removing persistent widgets When a persistent widget is removed, multiple calls to updateShowWidgetInPip happen in succession as each of the widget stores emit updates. But by depending on this.state.persistentWidgetId at the time of the call rather than passing an update function to setState, this had the effect that the removal of the widget could be reverted in the component's state, and so it could end up passing the ID of a removed widget to WidgetPip. * Re-public updateShowWidgetInPip so we don't change the interface --------- Co-authored-by: Robin Townsend <[email protected]>
1 parent 14e5ffb commit da2471f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/components/structures/PipContainer.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ class PipContainerInner extends React.Component<IProps, IState> {
192192
};
193193

194194
private onWidgetPersistence = (): void => {
195-
this.updateShowWidgetInPip(
196-
ActiveWidgetStore.instance.getPersistentWidgetId(),
197-
ActiveWidgetStore.instance.getPersistentRoomId(),
198-
);
195+
this.updateShowWidgetInPip();
199196
};
200197

201198
private onWidgetDockChanges = (): void => {
@@ -234,11 +231,10 @@ class PipContainerInner extends React.Component<IProps, IState> {
234231
}
235232
};
236233

237-
// Accepts a persistentWidgetId to be able to skip awaiting the setState for persistentWidgetId
238-
public updateShowWidgetInPip(
239-
persistentWidgetId = this.state.persistentWidgetId,
240-
persistentRoomId = this.state.persistentRoomId,
241-
): void {
234+
public updateShowWidgetInPip(): void {
235+
const persistentWidgetId = ActiveWidgetStore.instance.getPersistentWidgetId();
236+
const persistentRoomId = ActiveWidgetStore.instance.getPersistentRoomId();
237+
242238
let fromAnotherRoom = false;
243239
let notDocked = false;
244240
// Sanity check the room - the widget may have been destroyed between render cycles, and

0 commit comments

Comments
 (0)