Merge branch 'wio-tracker-l1-improvements' into wio-eink-unified

This commit is contained in:
Jakub
2026-05-23 10:22:52 +02:00
2 changed files with 42 additions and 6 deletions

View File

@@ -250,6 +250,21 @@ class QuickMsgScreen : public UIScreen {
if (!show_all && !(c.flags & 0x01)) continue;
_sorted[_num_contacts++] = i;
}
// Sort by message count descending; contacts with no messages keep original order.
int counts[MAX_CONTACTS];
for (int i = 0; i < _num_contacts; i++) {
the_mesh.getContactByIdx(_sorted[i], c);
counts[i] = dmHistCountForContact(c.id.pub_key);
}
for (int i = 1; i < _num_contacts; i++) {
if (counts[i] == 0) continue;
uint16_t key = _sorted[i]; int kc = counts[i];
int j = i;
while (j > 0 && counts[j-1] < kc) {
_sorted[j] = _sorted[j-1]; counts[j] = counts[j-1]; j--;
}
_sorted[j] = key; counts[j] = kc;
}
}
}