Skip to content

Conversation

paw-hub
Copy link
Contributor

@paw-hub paw-hub commented Sep 1, 2025

Closes #4419

@paw-hub paw-hub linked an issue Sep 1, 2025 that may be closed by this pull request
8 tasks
@paw-hub paw-hub force-pushed the 4419-drafts branch 22 times, most recently from a65b2cb to 515f5bb Compare September 3, 2025 10:50
This fixes a couple of problems with the throttle function.

First off, it wasn't actually being exported, so InboxRuleHandler was
importing it directly from its file. It's now correctly exported, and
it seems this was the *only* use of throttle.

Second off, lastArgs wasn't being saved, thus throttle wasn't actually
debouncing but just creating a new timeout for every invocation. For
example, if you called it 20 times with an interval of 5 seconds, it'd
just call it 20 times after a 5 second delay.

It now works like debounce() except that calling it does not restart the
timer. Hopefully this doesn't cause any spacebar heating (see xkcd 1172)
and InboxRuleHandler didn't actually depend on this behavior to work.
Fixes an oversight that can cause unintended data loss.

This oversight is caused by the fact that autosaving happens regardless
of if the draft was modified on another client.

Without this change, an autosave could (ironically) cause data loss if
the user has multiple clients and works on the draft on one client then
continues on another client. Because closing a draft automatically
saves the draft, it might save over the newer revision, causing data
loss.

For #4419 where the client will start periodically autosaving drafts,
the client will attempt to upload autosaved drafts on startup without
any input from the user. We only want an autosave to occur if this is
safe to do.

In the case that the user truly wants to save the draft, they can still
press CTRL-S (Command-S on macOS / iPadOS, etc.) to manually save the
draft while the draft editor is open.
@paw-hub paw-hub force-pushed the 4419-drafts branch 5 times, most recently from 054cad9 to b6910bc Compare September 4, 2025 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autosave drafts
1 participant