mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-03 03:11:57 +00:00
fix: messages that arrive while asleep or locked stay unread
A conversation left open under the lock screen or a dark display no longer counts as read: the counters and the lock screen's tally go up, and on waking (L2: on unlocking) the conversation reopens on its first unread under the "New" line, a typed draft kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1063,6 +1063,13 @@ public:
|
||||
_dm_hist_scroll = 0;
|
||||
_dm_fs.active = false;
|
||||
}
|
||||
// The display came back on over a conversation: what was filed while it was
|
||||
// dark is unread -- read on from its first message, as on opening.
|
||||
void onDisplayOn() {
|
||||
if (_ctx_menu.active) return;
|
||||
if (_phase == CHANNEL_HIST && !_fs.active && _history.chUnread(_sel_channel_idx) > 0) beginChannelView(_sel_channel_idx);
|
||||
else if (_phase == DM_HIST && !_dm_fs.active && _task->getDMUnread(_sel_contact.id.pub_key) > 0) beginDmView();
|
||||
}
|
||||
void beginChannelView(uint8_t channel_idx) {
|
||||
_sel_channel_idx = channel_idx;
|
||||
_unread_at_entry = (int)_history.chUnread(channel_idx);
|
||||
|
||||
@@ -2221,6 +2221,12 @@ void UITask::simUnread(int which) {
|
||||
}
|
||||
}
|
||||
|
||||
void UITask::simDisplay(bool on) {
|
||||
if (!_display) return;
|
||||
if (on) _display->turnOn(); else _display->turnOff();
|
||||
_next_refresh = 0;
|
||||
}
|
||||
|
||||
void UITask::simCompose(const char* text) {
|
||||
gotoMessagesScreen();
|
||||
((MessagesScreen*)messages_screen)->simCompose(text);
|
||||
@@ -2273,11 +2279,14 @@ void UITask::pickBotRoomTarget() {
|
||||
// ── UI Core wiring ──────────────────────────────────────────────────────────
|
||||
MyMesh::Listener* UITask::meshListener() { return _core; }
|
||||
|
||||
// On screen: a conversation left open under the lock or a dark display isn't read.
|
||||
bool UITask::isViewingChannel(uint8_t channel_idx) {
|
||||
return ((MessagesScreen*)messages_screen)->isViewingChannel(channel_idx);
|
||||
return curr == messages_screen && _display && _display->isOn() && !_locked
|
||||
&& ((MessagesScreen*)messages_screen)->isViewingChannel(channel_idx);
|
||||
}
|
||||
bool UITask::isViewingDM(const uint8_t* pub_key) {
|
||||
return ((MessagesScreen*)messages_screen)->isViewingDM(pub_key);
|
||||
return curr == messages_screen && _display && _display->isOn() && !_locked
|
||||
&& ((MessagesScreen*)messages_screen)->isViewingDM(pub_key);
|
||||
}
|
||||
void UITask::onViewedHistoryGrew(bool channel) {
|
||||
((MessagesScreen*)messages_screen)->onViewedHistoryGrew(channel);
|
||||
@@ -2732,6 +2741,11 @@ extern "C" EMSCRIPTEN_KEEPALIVE void sim_unread(int which) {
|
||||
if (g_sim_ui_task_for_js) g_sim_ui_task_for_js->simUnread(which);
|
||||
}
|
||||
|
||||
// Sim tests: the display off (0) or on (1), as the auto-off and a key press do.
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE void sim_display(int on) {
|
||||
if (g_sim_ui_task_for_js) g_sim_ui_task_for_js->simDisplay(on != 0);
|
||||
}
|
||||
|
||||
// Sim tests: a channel message arrives, alerted in Settings > Message alert's
|
||||
// style (0 Normal, 1 Compact, 2 Off).
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE void sim_message(const char* text, int style) {
|
||||
@@ -3155,6 +3169,11 @@ void UITask::loop() {
|
||||
#endif
|
||||
pollConnection(); // BLE link state -> hasConnection() (see UITaskBase)
|
||||
drainCoreEvents(); // react to what the Core filed during mesh processing (alerts, wake, sounds)
|
||||
{ // a conversation in view again (display on, unlocked): on to what came in meanwhile
|
||||
bool on = _display && _display->isOn() && !_locked;
|
||||
if (on && !_display_was_on && curr == messages_screen) ((MessagesScreen*)messages_screen)->onDisplayOn();
|
||||
_display_was_on = on;
|
||||
}
|
||||
if (status_screen) ((StatusScreen*)status_screen)->sample(); // Status history lines, once a minute
|
||||
#if UI_HAS_JOYSTICK
|
||||
uint8_t joy_rot = _node_prefs ? _node_prefs->joystick_rotation : JOYSTICK_ROTATION;
|
||||
|
||||
@@ -60,6 +60,7 @@ class UITask : public UITaskBase, public UiCoreHost {
|
||||
GenericVibration vibration;
|
||||
#endif
|
||||
unsigned long _next_refresh, _auto_off;
|
||||
bool _display_was_on = true; // loop(): the display back on and unlocked
|
||||
NodePrefs* _node_prefs;
|
||||
bool _locked;
|
||||
bool _tool_from_home = false;
|
||||
@@ -285,6 +286,7 @@ public:
|
||||
void simCompose(const char* text); // sim tests: a channel post's keyboard holding `text`
|
||||
void simMessage(const char* text); // sim tests: a channel message arrives
|
||||
void simUnread(int which); // sim tests: read and new messages, opened
|
||||
void simDisplay(bool on); // sim tests: the display off / on
|
||||
#endif
|
||||
void openContactDM(const ContactInfo& ci);
|
||||
void openChannelHistory(uint8_t channel_idx); // Favourites dial: open a pinned channel
|
||||
|
||||
Reference in New Issue
Block a user