Skip to content

Commit

Permalink
Merge pull request #5934 from nextcloud/backport/5930/stable29
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Jun 25, 2024
2 parents 666a04e + f7fcebf commit 71821d3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/services/PollingBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ const FETCH_INTERVAL_MAX = 5000
*/
const FETCH_INTERVAL_SINGLE_EDITOR = 5000

/**
* Interval to check for changes for read only users
* @type {number}
*/
const FETCH_INTERVAL_READ_ONLY = 30000

/**
* Interval to fetch for changes when a browser window is considered invisible by the
* page visibility API https://developer.mozilla.org/de/docs/Web/API/Page_Visibility_API
Expand Down Expand Up @@ -137,7 +143,9 @@ class PollingBackend {
}
const disconnect = Date.now() - COLLABORATOR_DISCONNECT_TIME
const alive = sessions.filter((s) => s.lastContact * 1000 > disconnect)
if (alive.length < 2) {
if (this.#syncService.connection.state.document.readOnly) {
this.maximumReadOnlyTimer()
} else if (alive.length < 2) {
this.maximumRefetchTimer()
} else {
this.increaseRefetchTimer()
Expand Down Expand Up @@ -210,6 +218,10 @@ class PollingBackend {
this.#fetchInterval = FETCH_INTERVAL_SINGLE_EDITOR
}

maximumReadOnlyTimer() {
this.#fetchInterval = FETCH_INTERVAL_READ_ONLY
}

visibilitychange() {
if (document.visibilityState === 'hidden') {
this.#fetchInterval = FETCH_INTERVAL_INVISIBLE
Expand Down

0 comments on commit 71821d3

Please sign in to comment.