Skip to content

Commit ff703ea

Browse files
committed
fix(Polling): Perform computations in milliseconds
The collaborator disconnect timeout is in ms as are all intervals. So we can directly subtract it from `Date.now()` - which also is in ms. The only time that is not expressed in ms is the last contact timestamp. Backport of #3769 Signed-off-by: Max <max@nextcloud.com>
1 parent ee34fea commit ff703ea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/services/PollingBackend.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ class PollingBackend {
154154
return
155155
}
156156
this.lock = false
157-
if (response.data.sessions.filter((session) => session.lastContact > Date.now() / 1000 - COLLABORATOR_DISCONNECT_TIME).length < 2) {
157+
const disconnect = Date.now() - COLLABORATOR_DISCONNECT_TIME
158+
const alive = response.data.sessions.filter((s) => s.lastContact * 1000 > disconnect)
159+
if (alive.length < 2) {
158160
this.maximumRefetchTimer()
159161
} else {
160162
this.increaseRefetchTimer()

0 commit comments

Comments
 (0)