mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 10:16:11 +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:
co-authored by
Claude Sonnet 4.6
parent
27384e4fc9
commit
ed2978a5a0
@@ -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() {
|
void reset() {
|
||||||
_phase = MODE_SELECT;
|
_phase = MODE_SELECT;
|
||||||
_mode_sel = 0;
|
_mode_sel = 0;
|
||||||
@@ -1950,16 +1956,14 @@ public:
|
|||||||
} else if (_page == HomePage::QUICK_MSG) {
|
} else if (_page == HomePage::QUICK_MSG) {
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.drawTextCentered(display.width() / 2, 30, "Messages");
|
display.drawTextCentered(display.width() / 2, 22, "Messages");
|
||||||
int dm_unread = _task->getMsgCount();
|
int total_unread = _task->getMsgCount() + _task->getChannelUnreadCount();
|
||||||
if (dm_unread > 0) {
|
if (total_unread > 0) {
|
||||||
char badge[16];
|
char badge[20];
|
||||||
snprintf(badge, sizeof(badge), "%d unread DM", dm_unread);
|
snprintf(badge, sizeof(badge), "%d unread", total_unread);
|
||||||
display.drawTextCentered(display.width() / 2, 41, badge);
|
display.drawTextCentered(display.width() / 2, 35, 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, 50, PRESS_LABEL " to open");
|
||||||
} else if (_page == HomePage::SHUTDOWN) {
|
} else if (_page == HomePage::SHUTDOWN) {
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
@@ -2257,6 +2261,10 @@ void UITask::addChannelMsg(uint8_t channel_idx, const char* text) {
|
|||||||
((QuickMsgScreen*)quick_msg)->addChannelMsg(channel_idx, 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) {
|
void UITask::showAlert(const char* text, int duration_millis) {
|
||||||
strcpy(_alert, text);
|
strcpy(_alert, text);
|
||||||
_alert_expiry = millis() + duration_millis;
|
_alert_expiry = millis() + duration_millis;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public:
|
|||||||
void showAlert(const char* text, int duration_millis);
|
void showAlert(const char* text, int duration_millis);
|
||||||
void addChannelMsg(uint8_t channel_idx, const char* text) override;
|
void addChannelMsg(uint8_t channel_idx, const char* text) override;
|
||||||
int getMsgCount() const { return _msgcount; }
|
int getMsgCount() const { return _msgcount; }
|
||||||
|
int getChannelUnreadCount() const;
|
||||||
bool hasDisplay() const { return _display != NULL; }
|
bool hasDisplay() const { return _display != NULL; }
|
||||||
bool isButtonPressed() const;
|
bool isButtonPressed() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user