mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 10:45:20 -04: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)
|
const rendererReady = useApplicationState((state) => state.rendererStatus.rendererReady)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (rendererReady && scrollState && !equal(scrollState, oldScrollState.current)) {
|
if (
|
||||||
|
iframeCommunicator.isCommunicationEnabled() &&
|
||||||
|
rendererReady &&
|
||||||
|
scrollState &&
|
||||||
|
!equal(scrollState, oldScrollState.current)
|
||||||
|
) {
|
||||||
oldScrollState.current = scrollState
|
oldScrollState.current = scrollState
|
||||||
iframeCommunicator.sendMessageToOtherSide({ type: CommunicationMessageType.SET_SCROLL_STATE, scrollState })
|
iframeCommunicator.sendMessageToOtherSide({ type: CommunicationMessageType.SET_SCROLL_STATE, scrollState })
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,10 @@ export abstract class WindowPostMessageCommunicator<
|
||||||
this.communicationEnabled = true
|
this.communicationEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isCommunicationEnabled(): boolean {
|
||||||
|
return this.communicationEnabled
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the message target.
|
* Sends a message to the message target.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue