Files
webmail/lib/store-epoch.ts
Linus Rath e98a0e6351 fix: drop folder and filter fetches that finish after an account switch
A folder or filter fetch started for one account and answered after a
switch wrote its result into the stores the next account had just
filled. The sidebar then showed the old account's folders, and the
filter store kept the old account's rules and script id, so the next
save uploaded them - a redirect to someone else's address included -
to the new account's server.

Clearing the stores for another account now bumps a store epoch.
`fetchMailboxes` and the email list's view check drop results from an
older epoch, and the filter store drops any fetch that is no longer the
latest one.
2026-09-26 15:31:05 +02:00

17 lines
517 B
TypeScript

/**
* Bumped whenever the account-scoped stores are emptied for another account
* (an account switch, a sign-out). A fetch captures it before awaiting the
* server and drops its result if it has changed since: the data belongs to
* an account that is no longer on screen, and writing it would show - and
* let the user act on - one account's folders or filters in another.
*/
let epoch = 0;
export function currentStoreEpoch(): number {
return epoch;
}
export function bumpStoreEpoch(): void {
epoch++;
}