Take the filing action, not the whole rule
Deleting a folder removed every rule that filed into it, along with whatever else those rules did. A rule that filed into Work, marked read and stopped processing lost the marking and the stopping too, and deleting a folder says nothing about whether those were still wanted. Only the fileinto action goes now. A rule left with nothing to do is still removed, because it has nothing to do; a rule filing into two folders keeps the one that still exists. The toast says which happened. Verified against the running app with two rules aimed at the same folder, one filing only and one filing and marking read: the first was removed, the second kept its markread, and the script stored on the server agrees.
This commit is contained in:
@@ -1069,16 +1069,18 @@ async function followFolders(before: FolderRef[]): Promise<void> {
|
||||
else gone.push(ref);
|
||||
}
|
||||
|
||||
const { retargetRules, dropRulesForFolders } = await import("@/lib/sieveFolders");
|
||||
const { retargetRules, detachFolders } = await import("@/lib/sieveFolders");
|
||||
const retargeted = retargetRules(rules, moves);
|
||||
const dropped = dropRulesForFolders(retargeted.rules, gone);
|
||||
if (!retargeted.changed && !dropped.removed.length) return;
|
||||
const detached = detachFolders(retargeted.rules, gone);
|
||||
if (!retargeted.changed && !detached.edited.length && !detached.removed.length) return;
|
||||
|
||||
await useSieve.getState().saveRules(dropped.rules);
|
||||
await useSieve.getState().saveRules(detached.rules);
|
||||
const { toast } = await import("@/ui/toast");
|
||||
const plural = (n: number) => (n === 1 ? "" : "s");
|
||||
const said: string[] = [];
|
||||
if (retargeted.changed) said.push(`${retargeted.changed} filter rule${retargeted.changed === 1 ? "" : "s"} updated`);
|
||||
if (dropped.removed.length) said.push(`${dropped.removed.length} filter rule${dropped.removed.length === 1 ? "" : "s"} removed: ${dropped.removed.map((r) => `“${r.name}”`).join(", ")}`);
|
||||
if (retargeted.changed) said.push(`${retargeted.changed} filter rule${plural(retargeted.changed)} updated`);
|
||||
if (detached.edited.length) said.push(`${detached.edited.length} filter rule${plural(detached.edited.length)} no longer file${detached.edited.length === 1 ? "s" : ""} there`);
|
||||
if (detached.removed.length) said.push(`${detached.removed.length} filter rule${plural(detached.removed.length)} removed, having nothing left to do: ${detached.removed.map((r) => `“${r.name}”`).join(", ")}`);
|
||||
toast.show(said.join(" · "), { duration: 8000 });
|
||||
} catch (err) {
|
||||
const { toast } = await import("@/ui/toast");
|
||||
|
||||
Reference in New Issue
Block a user