diff options
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/modules/mail/Accounts.qml | 22 | ||||
| -rw-r--r-- | desktop/modules/mail/README.md | 6 |
2 files changed, 28 insertions, 0 deletions
diff --git a/desktop/modules/mail/Accounts.qml b/desktop/modules/mail/Accounts.qml index 0ae6886..c2bc9d8 100644 --- a/desktop/modules/mail/Accounts.qml +++ b/desktop/modules/mail/Accounts.qml @@ -184,6 +184,28 @@ Singleton { accounts = next; } + // Recount whenever the notmuch database commits. Without this the counts + // were read only at shell start and when the mail page opened, so the + // tile drifted behind the real inbox for the rest of the session. + // + // The directory is watched, not a file: Xapian replaces its files on + // commit, which kills a watch held on any one of them. notmuch is asked + // for its own database path, so a moved database needs no edit here. + Process { + id: watcher + running: true + command: ["sh", "-c", + 'exec inotifywait -m -q -e close_write,moved_to --format x "$(notmuch config get database.path)/xapian"'] + // One commit touches several files; the timer turns that burst into + // one refresh. + stdout: SplitParser { onRead: debounce.restart() } + // A dead watcher is the original bug again, silently. Come back. + onExited: respawn.start() + } + + Timer { id: debounce; interval: 300; onTriggered: root.refresh() } + Timer { id: respawn; interval: 5000; onTriggered: watcher.running = true } + // Launching qtmaildir. It takes no arguments, so there is nothing to tell // it about the account or thread clicked. Process { id: openProc; command: [`${Quickshell.env("HOME")}/bin/qtmaildir`] } diff --git a/desktop/modules/mail/README.md b/desktop/modules/mail/README.md index 3b9f89e..ced87f3 100644 --- a/desktop/modules/mail/README.md +++ b/desktop/modules/mail/README.md @@ -61,6 +61,12 @@ back is a legitimate path for an account with no label. ## Counting +**The counts follow the database, not the drawer.** `Accounts` runs its own +`inotifywait -m` on the xapian directory and recounts 300ms after a commit +burst settles. Before that it counted only at shell start and on opening the +page, so the tile read 14 while the inbox held 16. The watcher respawns after +5s if it dies, since a dead one reproduces that drift silently. + Every count is `tag:unread and tag:inbox`. Plain `tag:unread` also counts archived-but-unread mail and mailing list traffic that was never in the inbox, which for one account here was the difference between 32 and 41; the |
