sync new message message read or unread notification display better between device ui and ble app; keep in channel after message sent, moved sent toaster popup to in channel

This commit is contained in:
pelgraine
2026-03-01 08:01:47 +11:00
parent a536196fd7
commit 2163a4c56c
6 changed files with 30 additions and 6 deletions

View File

@@ -48,6 +48,9 @@ public:
virtual void forceRefresh() {}
virtual void addSentChannelMessage(uint8_t channel_idx, const char* sender, const char* text) {}
// Mark a channel as read when BLE companion app syncs a message
virtual void markChannelReadFromBLE(uint8_t channel_idx) {}
// Repeater admin callbacks (from MyMesh)
virtual void onAdminLoginResult(bool success, uint8_t permissions, uint32_t server_time) {}
virtual void onAdminCliResponse(const char* from_name, const char* text) {}

View File

@@ -1410,7 +1410,19 @@ void MyMesh::handleCmdFrame(size_t len) {
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
_serial->writeFrame(out_frame, out_len);
#ifdef DISPLAY_CLASS
if (_ui) _ui->msgRead(offline_queue_len);
if (_ui) {
_ui->msgRead(offline_queue_len);
// Mark channel as read when BLE companion app syncs the message.
// Frame layout V3: [resp_code][snr][res1][res2][channel_idx][path_len]...
// Frame layout V1: [resp_code][channel_idx][path_len]...
bool is_v3_ch = (out_frame[0] == RESP_CODE_CHANNEL_MSG_RECV_V3);
bool is_old_ch = (out_frame[0] == RESP_CODE_CHANNEL_MSG_RECV);
if (is_v3_ch || is_old_ch) {
uint8_t ch_idx = is_v3_ch ? out_frame[4] : out_frame[1];
_ui->markChannelReadFromBLE(ch_idx);
}
}
#endif
} else {
out_frame[0] = RESP_CODE_NO_MORE_MESSAGES;

View File

@@ -1156,7 +1156,7 @@ void handleKeyboardInput() {
if (wasDM) {
ui_task.gotoContactsScreen();
} else {
ui_task.gotoHomeScreen();
ui_task.gotoChannelScreen();
}
return;
}
@@ -1176,7 +1176,7 @@ void handleKeyboardInput() {
if (wasDM) {
ui_task.gotoContactsScreen();
} else {
ui_task.gotoHomeScreen();
ui_task.gotoChannelScreen();
}
return;
}

View File

@@ -5,7 +5,7 @@
#include <MeshCore.h>
// Forward declarations
class UITask;
#include "../AbstractUITask.h"
class MyMesh;
extern MyMesh the_mesh;
@@ -165,7 +165,7 @@ public:
};
private:
UITask* _task;
AbstractUITask* _task;
mesh::RTCClock* _rtc;
AdminState _state;
@@ -421,7 +421,7 @@ private:
}
public:
RepeaterAdminScreen(UITask* task, mesh::RTCClock* rtc)
RepeaterAdminScreen(AbstractUITask* task, mesh::RTCClock* rtc)
: _task(task), _rtc(rtc), _state(STATE_PASSWORD_ENTRY),
_contactIdx(-1), _permissions(0), _serverTime(0),
_pwdLen(0), _lastCharAt(0),

View File

@@ -1486,6 +1486,12 @@ void UITask::addSentChannelMessage(uint8_t channel_idx, const char* sender, cons
((ChannelScreen *) channel_screen)->addMessage(channel_idx, 0, sender, formattedMsg);
}
void UITask::markChannelReadFromBLE(uint8_t channel_idx) {
((ChannelScreen *) channel_screen)->markChannelRead(channel_idx);
// Trigger a refresh so the home screen unread count updates in real-time
_next_refresh = millis() + 200;
}
void UITask::gotoRepeaterAdmin(int contactIdx) {
// Lazy-initialize on first use (same pattern as audiobook player)
if (repeater_admin == nullptr) {

View File

@@ -155,6 +155,9 @@ public:
// Add a sent message to the channel screen history
void addSentChannelMessage(uint8_t channel_idx, const char* sender, const char* text) override;
// Mark channel as read when BLE companion app syncs messages
void markChannelReadFromBLE(uint8_t channel_idx) override;
// Repeater admin callbacks
void onAdminLoginResult(bool success, uint8_t permissions, uint32_t server_time) override;
void onAdminCliResponse(const char* from_name, const char* text) override;