From 15cb4300a5eceb150c901be94a987eda78768e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 7 Nov 2021 21:23:23 +0100 Subject: [PATCH] cursors add currentEmpty. --- internal/websocket/manager.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/websocket/manager.go b/internal/websocket/manager.go index 6da1896c..a753d23a 100644 --- a/internal/websocket/manager.go +++ b/internal/websocket/manager.go @@ -309,7 +309,8 @@ func (manager *WebSocketManagerCtx) inactiveCursors() { ticker := time.NewTicker(inactiveCursorsPeriod) defer ticker.Stop() - lastEmpty := false + var currentEmpty bool + var lastEmpty = false for { select { @@ -319,11 +320,11 @@ func (manager *WebSocketManagerCtx) inactiveCursors() { case <-ticker.C: cursorsMap := manager.sessions.PopCursors() - length := len(cursorsMap) - if length == 0 && lastEmpty { + currentEmpty = len(cursorsMap) == 0 + if currentEmpty && lastEmpty { continue } - lastEmpty = length == 0 + lastEmpty = currentEmpty cursors := []message.SessionCursor{} for session, cursor := range cursorsMap {