diff --git a/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/WindowSizeController.kt b/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/WindowSizeController.kt index 342ffe4c..96365dae 100644 --- a/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/WindowSizeController.kt +++ b/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/WindowSizeController.kt @@ -50,13 +50,8 @@ class WindowSizeController(private val stateMachine: ClientStateMachine) { stateMachine.fire(ClientAction.WindowResize) } - private var listening = false - - fun addListenerIfNeeded() { - if (!listening) { - window.addEventListener(RESIZE_EVENT_TYPE, ::handleResizeEvent) - listening = true - } + init { + window.addEventListener(RESIZE_EVENT_TYPE, ::handleResizeEvent) } companion object { diff --git a/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/state/ClientState.kt b/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/state/ClientState.kt index 48eab913..d44ebbf5 100644 --- a/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/state/ClientState.kt +++ b/projector-client-web/src/main/kotlin/org/jetbrains/projector/client/web/state/ClientState.kt @@ -172,10 +172,6 @@ sealed class ClientState { private val onHandshakeFinish: () -> Unit = {}, ) : ClientState() { - init { - windowSizeController.addListenerIfNeeded() - } - override fun consume(action: ClientAction) = when (action) { is ClientAction.WebSocket.Open -> { OnScreenMessenger.showText("Connection is opened", "Sending handshake...", canReload = false)