mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 10:46:30 -05:00
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:
parent
c8254ff779
commit
b7b0021ff7
2 changed files with 10 additions and 1 deletions
|
@ -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 })
|
||||
}
|
||||
|
|
|
@ -93,6 +93,10 @@ export abstract class WindowPostMessageCommunicator<
|
|||
this.communicationEnabled = true
|
||||
}
|
||||
|
||||
public isCommunicationEnabled(): boolean {
|
||||
return this.communicationEnabled
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the message target.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue