app/core/FolderArrivalWatcher.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "app/core/FolderArrivalWatcher.h" | ||
| 2 | |||
| 3 | // F-36/F-50 (SPRINT-104): see FolderArrivalWatcher.h. One deliberate | ||
| 4 | // limitation recorded in the ledger: a rise that comes from mail this | ||
| 5 | // session moved unread into the folder, or from unread marks made on | ||
| 6 | // another device, notifies as well — the count is the only signal, and a | ||
| 7 | // folder-naming popup for a rare false positive beats the silent | ||
| 8 | // false negatives of the old Inbox-only chain. | ||
| 9 | |||
| 10 | namespace { | ||
| 11 | 114 | QString keyOf(const QString &account, const QString &folder) { | |
| 12 |
2/2✓ Branch 4 → 5 taken 114 times.
✓ Branch 5 → 6 taken 114 times.
|
114 | return account + QLatin1Char('\x1f') + folder; |
| 13 | } | ||
| 14 | } // namespace | ||
| 15 | |||
| 16 | 798 | FolderArrivalWatcher::FolderArrivalWatcher(Deps deps, QObject *parent) | |
| 17 | 798 | : QObject(parent), m_deps(std::move(deps)) {} | |
| 18 | |||
| 19 | 114 | void FolderArrivalWatcher::onUnreadCount(const QString &account, const QString &folderPath, | |
| 20 | int unread) { | ||
| 21 |
1/1✓ Branch 2 → 3 taken 114 times.
|
114 | const QString key = keyOf(account, folderPath); |
| 22 |
1/1✓ Branch 3 → 4 taken 114 times.
|
114 | const auto it = m_baseline.find(key); |
| 23 |
2/2✓ Branch 6 → 7 taken 52 times.
✓ Branch 6 → 9 taken 62 times.
|
114 | if (it == m_baseline.end()) { |
| 24 |
1/1✓ Branch 7 → 8 taken 52 times.
|
52 | m_baseline.insert(key, unread); |
| 25 | 52 | return; | |
| 26 | } | ||
| 27 | 62 | const int previous = *it; | |
| 28 | 62 | *it = unread; | |
| 29 |
4/5✓ Branch 12 → 13 taken 62 times.
✗ Branch 12 → 16 not taken.
✓ Branch 13 → 14 taken 62 times.
✓ Branch 14 → 15 taken 38 times.
✓ Branch 14 → 16 taken 24 times.
|
62 | const bool reading = m_deps.isReading && m_deps.isReading(account, folderPath); |
| 30 |
4/4✓ Branch 17 → 18 taken 18 times.
✓ Branch 17 → 20 taken 44 times.
✓ Branch 18 → 19 taken 15 times.
✓ Branch 18 → 20 taken 3 times.
|
62 | if (unread > previous && !reading) |
| 31 |
1/1✓ Branch 19 → 20 taken 15 times.
|
15 | emit arrivalsDetected(account, folderPath, unread - previous); |
| 32 | 114 | } | |
| 33 |