Skip to content

Conversation

@max-nextcloud
Copy link
Collaborator

@max-nextcloud max-nextcloud commented Apr 10, 2025

Fixes: #6877

enh(sync): add useDelayedFlag

Allow changing a flag with different delays:

  • Switch it on slow.
  • Switch it off fast.

Useful for errors - so they only show after a while but are resolved quickly.

Example:

const input = ref(false)
const { delayed } = useDelayedFlag(input)
...
input.value = true
// 5 seconds later delayed.value will be true
...
input.value = false
// 200 ms later delayed.value will be true

fix(sync): allow writing during short connection failures

Delay the error message and allow editing for 5 seconds.
Also speed up the recovery by triggering push after a successful sync.

Allow changing a flag with different delays:
* Switch it on slow.
* Switch it off fast.

Useful for errors - so they only show after a while but are resolved quickly.

Example:

const input = ref(false)
const { delayed } = useDelayedFlag(input)
...
input.value = true
// 5 seconds later delayed.value will be true
...
input.value = false
// 200 ms later delayed.value will be true

Signed-off-by: Max <[email protected]>
@codecov
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.86%. Comparing base (1b2e929) to head (1676004).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7093      +/-   ##
==========================================
+ Coverage   51.83%   51.86%   +0.02%     
==========================================
  Files         477      478       +1     
  Lines       40681    40705      +24     
  Branches      988      993       +5     
==========================================
+ Hits        21089    21112      +23     
- Misses      19487    19488       +1     
  Partials      105      105              

☔ 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.

Delay the error message and allow editing for 5 seconds.
Also speed up the recovery by triggering push after a successful sync.

Signed-off-by: Max <[email protected]>
@max-nextcloud max-nextcloud marked this pull request as ready for review April 10, 2025 08:50
@max-nextcloud max-nextcloud requested a review from mejo- as a code owner April 10, 2025 08:50
if (timeout) {
clearTimeout(timeout)
}
const delay = val ? 5000 : 200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we still wait 200ms when switching back? Can't we do it instantly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to reduce the risk of a flickering state. Basically if the error goes away for a brief moment and comes back right after.

But thinking about it again I cannot see how that would happen within 200 ms. The error will only go away after the push request - which may be triggered by a successful sync. So then the next sync will be longer than 200 ms away. So I guess we can save the 200 ms and just remove the flag immediately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, that sounds good the still to keep.

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small question inline, otherwise very nice

@juliusknorr juliusknorr added the bug Something isn't working label Apr 11, 2025
@juliusknorr juliusknorr added this to the Nextcloud 32 milestone Apr 11, 2025
@juliusknorr juliusknorr merged commit ef7f251 into main Apr 11, 2025
66 checks passed
@juliusknorr juliusknorr deleted the fix/reload-message branch April 11, 2025 05:31
@juliusknorr
Copy link
Member

/backport to stable31

@juliusknorr
Copy link
Member

/backport to stable30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow continue writing during short reconnect process.

4 participants