aboutsummaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-26 16:22:49 +0200
committerDanilo M. <danix@danix.xyz>2026-08-26 16:22:49 +0200
commit496e174e65c06563aff426bdbbeeba006102e89d (patch)
treec43c434598fbfca36055a1cd7487fecb1dffce5f /src/mainwindow.cpp
parent409faeadf013952420963fa1b740d44526d8a95e (diff)
downloadqtmaildir-496e174e65c06563aff426bdbbeeba006102e89d.tar.gz
qtmaildir-496e174e65c06563aff426bdbbeeba006102e89d.zip
feat: propose business senders from newly synced mail
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index ec43b3c..a09a572 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2589,6 +2589,20 @@ void MainWindow::wireWorker()
connect(m_worker, &NotmuchWorker::messageCountsReady,
this, &MainWindow::onRuleCountsReady);
+ // Sender counts feed the business-senders candidate list after a sync.
+ // The connection is queued, so the QHash argument must be a registered
+ // metatype; notmuchworker.cpp registers it beside SortOrder.
+ connect(m_worker, &NotmuchWorker::senderCountsReady, this,
+ [this](const QHash<QString, int> &counts) {
+ // Never applies anything: appendCandidates writes commented
+ // lines only, so nothing on screen changes until the user
+ // uncomments one. The list is then reloaded so an entry they
+ // uncommented by hand takes effect without a restart.
+ BusinessSenders::appendCandidates(
+ BusinessSenders::defaultPath(), counts);
+ loadBusinessSenders();
+ });
+
// The rules dialog is the only consumer, and it may have been closed while
// the scan was in flight. No generation counter: the tree on disk does not
// change under a query, so a late answer is still the right one.
@@ -4351,6 +4365,14 @@ void MainWindow::onSyncFinished(bool success, int exitCode)
refreshCurrentQuery();
// A sync is the usual way new tags enter the database.
requestAllTags();
+
+ // Propose new business-sender candidates from the mail this sync
+ // delivered. Scoped by scanQuery: a week of mail once the file
+ // exists, everything on the first run.
+ QMetaObject::invokeMethod(
+ m_worker, "countSenders", Qt::QueuedConnection,
+ Q_ARG(QString,
+ BusinessSenders::scanQuery(BusinessSenders::defaultPath())));
} else if (exitCode == kSyncSkippedExitCode) {
// Skipped means the lock was never ours: some other run holds it. If
// both started inside the same poll interval the monitor will have