mirror of https://github.com/vector-im/riot-web
				
				
				
			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 <robin@robin.town>pull/28788/head^2
							parent
							
								
									14e5ffbd31
								
							
						
					
					
						commit
						da2471ffbd
					
				|  | @ -192,10 +192,7 @@ class PipContainerInner extends React.Component<IProps, IState> { | |||
|     }; | ||||
| 
 | ||||
|     private onWidgetPersistence = (): void => { | ||||
|         this.updateShowWidgetInPip( | ||||
|             ActiveWidgetStore.instance.getPersistentWidgetId(), | ||||
|             ActiveWidgetStore.instance.getPersistentRoomId(), | ||||
|         ); | ||||
|         this.updateShowWidgetInPip(); | ||||
|     }; | ||||
| 
 | ||||
|     private onWidgetDockChanges = (): void => { | ||||
|  | @ -234,11 +231,10 @@ class PipContainerInner extends React.Component<IProps, IState> { | |||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     // Accepts a persistentWidgetId to be able to skip awaiting the setState for persistentWidgetId
 | ||||
|     public updateShowWidgetInPip( | ||||
|         persistentWidgetId = this.state.persistentWidgetId, | ||||
|         persistentRoomId = this.state.persistentRoomId, | ||||
|     ): void { | ||||
|     public updateShowWidgetInPip(): void { | ||||
|         const persistentWidgetId = ActiveWidgetStore.instance.getPersistentWidgetId(); | ||||
|         const persistentRoomId = ActiveWidgetStore.instance.getPersistentRoomId(); | ||||
| 
 | ||||
|         let fromAnotherRoom = false; | ||||
|         let notDocked = false; | ||||
|         // Sanity check the room - the widget may have been destroyed between render cycles, and
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Andy Balaam
						Andy Balaam