fix(frontend): don't send scroll state if window post message communicator isn't ready

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-12-28 15:02:25 +01:00
parent c8254ff779
commit b7b0021ff7
2 changed files with 10 additions and 1 deletions

View file

@ -21,7 +21,12 @@ export const useSendScrollState = (scrollState: ScrollState | undefined): void =
const rendererReady = useApplicationState((state) => state.rendererStatus.rendererReady)
useEffect(() => {
if (rendererReady && scrollState && !equal(scrollState, oldScrollState.current)) {
if (
iframeCommunicator.isCommunicationEnabled() &&
rendererReady &&
scrollState &&
!equal(scrollState, oldScrollState.current)
) {
oldScrollState.current = scrollState
iframeCommunicator.sendMessageToOtherSide({ type: CommunicationMessageType.SET_SCROLL_STATE, scrollState })
}

View file

@ -93,6 +93,10 @@ export abstract class WindowPostMessageCommunicator<
this.communicationEnabled = true
}
public isCommunicationEnabled(): boolean {
return this.communicationEnabled
}
/**
* Sends a message to the message target.
*