mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
Home Messages page: show total unread count (DM + all channels)
Sums getMsgCount() (DM unreads) and getTotalChannelUnread() (sum of _ch_unread[] across all channels) and displays "N unread" under the "Messages" heading when non-zero. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -911,6 +911,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
int getTotalChannelUnread() const {
|
||||
int total = 0;
|
||||
for (int i = 0; i < MAX_GROUP_CHANNELS; i++) total += _ch_unread[i];
|
||||
return total;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_phase = MODE_SELECT;
|
||||
_mode_sel = 0;
|
||||
@@ -1950,16 +1956,14 @@ public:
|
||||
} else if (_page == HomePage::QUICK_MSG) {
|
||||
display.setColor(DisplayDriver::LIGHT);
|
||||
display.setTextSize(1);
|
||||
display.drawTextCentered(display.width() / 2, 30, "Messages");
|
||||
int dm_unread = _task->getMsgCount();
|
||||
if (dm_unread > 0) {
|
||||
char badge[16];
|
||||
snprintf(badge, sizeof(badge), "%d unread DM", dm_unread);
|
||||
display.drawTextCentered(display.width() / 2, 41, badge);
|
||||
display.drawTextCentered(display.width() / 2, 54, PRESS_LABEL " to open");
|
||||
} else {
|
||||
display.drawTextCentered(display.width() / 2, 46, PRESS_LABEL " to open");
|
||||
display.drawTextCentered(display.width() / 2, 22, "Messages");
|
||||
int total_unread = _task->getMsgCount() + _task->getChannelUnreadCount();
|
||||
if (total_unread > 0) {
|
||||
char badge[20];
|
||||
snprintf(badge, sizeof(badge), "%d unread", total_unread);
|
||||
display.drawTextCentered(display.width() / 2, 35, badge);
|
||||
}
|
||||
display.drawTextCentered(display.width() / 2, 50, PRESS_LABEL " to open");
|
||||
} else if (_page == HomePage::SHUTDOWN) {
|
||||
display.setColor(DisplayDriver::LIGHT);
|
||||
display.setTextSize(1);
|
||||
@@ -2257,6 +2261,10 @@ void UITask::addChannelMsg(uint8_t channel_idx, const char* text) {
|
||||
((QuickMsgScreen*)quick_msg)->addChannelMsg(channel_idx, text);
|
||||
}
|
||||
|
||||
int UITask::getChannelUnreadCount() const {
|
||||
return ((QuickMsgScreen*)quick_msg)->getTotalChannelUnread();
|
||||
}
|
||||
|
||||
void UITask::showAlert(const char* text, int duration_millis) {
|
||||
strcpy(_alert, text);
|
||||
_alert_expiry = millis() + duration_millis;
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
void showAlert(const char* text, int duration_millis);
|
||||
void addChannelMsg(uint8_t channel_idx, const char* text) override;
|
||||
int getMsgCount() const { return _msgcount; }
|
||||
int getChannelUnreadCount() const;
|
||||
bool hasDisplay() const { return _display != NULL; }
|
||||
bool isButtonPressed() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user