Skip to content

Conversation

@backportbot
Copy link

@backportbot backportbot bot commented Apr 2, 2025

Backport of PR #6798

mejo- added 2 commits April 2, 2025 14:03
It used to check if the last saved version of the document is older than
the current version. But `document.currentVersion` no longer exists in
the backend response, so this didn't work since quite some time.

Signed-off-by: Jonas <[email protected]>
This will send a final save request on unsaved changes via the browsers
native `navigator.sendBeacon()` function when navigating away from the
website or the tab/browser is closed.

Fixes: #6606

Implementation details:
* While `beforeunload` event is less reliable than `visibilitychange`
  according to different sources on the internet, tests in Firefox on
  Linux desktop revealed that `visibilitychange` event doesn't fire when
  opening a new website in the same tab. `beforeunload` on the other
  hand reliably worked when switching web page and closing tab/browser.
* We add and remove the `beforeunload` event with every `dirty` state
  change because according to MDN documentation websites with a
  registered `beforeunload` event don't benefit from bfcache optimization.
  See https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event

Signed-off-by: Jonas <[email protected]>
@backportbot backportbot bot requested a review from max-nextcloud April 2, 2025 14:03
@backportbot backportbot bot added bug Something isn't working 3. to review labels Apr 2, 2025
@backportbot backportbot bot added this to the Nextcloud 31.0.3 milestone Apr 2, 2025
@codecov
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 32.55814% with 29 lines in your changes missing coverage. Please review.

Project coverage is 58.99%. Comparing base (e01ef6d) to head (c374fa8).
Report is 11 commits behind head on stable31.

Files with missing lines Patch % Lines
src/services/SessionApi.js 0.00% 18 Missing ⚠️
src/services/SyncService.js 0.00% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           stable31    #7062      +/-   ##
============================================
- Coverage     59.02%   58.99%   -0.03%     
============================================
  Files           285      285              
  Lines         35836    35865      +29     
  Branches        788      788              
============================================
+ Hits          21151    21159       +8     
- Misses        14565    14586      +21     
  Partials        120      120              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mejo- mejo- merged commit 0282154 into stable31 Apr 2, 2025
62 of 64 checks passed
@mejo- mejo- deleted the backport/6798/stable31 branch April 2, 2025 14:18
@Altahrim Altahrim mentioned this pull request Apr 3, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants