Skip to content

Commit 83ef60c

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 1d42608 commit 83ef60c

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
@@ -153,7 +153,9 @@ class PollingBackend {
153153
return
154154
}
155155
this.lock = false
156-
if (response.data.sessions.filter((session) => session.lastContact > Date.now() / 1000 - COLLABORATOR_DISCONNECT_TIME).length < 2) {
156+
const disconnect = Date.now() - COLLABORATOR_DISCONNECT_TIME
157+
const alive = response.data.sessions.filter((s) => s.lastContact * 1000 > disconnect)
158+
if (alive.length < 2) {
157159
this.maximumRefetchTimer()
158160
} else {
159161
this.increaseRefetchTimer()

0 commit comments

Comments
 (0)