mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 10:46:12 +00:00
fix(companion): show the sender's own timestamp for synced/queued messages
DM, room and channel history always stamped a message with receipt time (rtc_clock.getCurrentTime()), even though the sender's real timestamp was already available (and, for DMs/rooms, already threaded through to addDMMsg -- just never used for display). Live-received messages hid this because receipt lags origination by only seconds, but a room-sync replay or an offline-queued message held by a repeater can arrive long after it was sent, so a burst of backlog messages all showed as "just now". storeDMMsg() now prefers msg_ts (falling back to receipt time only when unknown). addChannelMsg() gained a timestamp parameter, threaded from onChannelMessageRecv() down through AbstractUITask/UITask, with the same fallback. The DM dedup check and outgoing-message timestamps are unaffected (they use msg_ts directly, already correct). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6a394e2d7a
commit
7a5247d5d4
@@ -398,7 +398,11 @@ class QuickMsgScreen : public UIScreen {
|
||||
}
|
||||
memcpy(_dm_hist[pos].prefix, pub_key, 4);
|
||||
_dm_hist[pos].outgoing = outgoing ? 1 : 0;
|
||||
_dm_hist[pos].timestamp = rtc_clock.getCurrentTime();
|
||||
// Prefer the sender's own timestamp — a room-sync replay or an
|
||||
// offline-queued message held by a repeater can arrive long after it was
|
||||
// actually sent, so "now" would mislabel every backlog message as fresh.
|
||||
// Fall back to receipt time only when the sender's timestamp is unknown.
|
||||
_dm_hist[pos].timestamp = msg_ts ? msg_ts : rtc_clock.getCurrentTime();
|
||||
strncpy(_dm_hist[pos].text, text, sizeof(DmHistEntry::text) - 1);
|
||||
_dm_hist[pos].text[sizeof(DmHistEntry::text) - 1] = '\0';
|
||||
_dm_hist[pos].ack_status = (outgoing && ack_tag) ? ACK_PENDING : ACK_NONE;
|
||||
@@ -677,8 +681,10 @@ public:
|
||||
}
|
||||
|
||||
// Returns the ring position the message was stored at, or -1 if rejected, so
|
||||
// the outgoing path can attach a relay seq to that exact entry.
|
||||
int addChannelMsg(uint8_t ch_idx, const char* text) {
|
||||
// the outgoing path can attach a relay seq to that exact entry. `timestamp`
|
||||
// is the sender's own send time (0 = unknown/outgoing — use receipt time);
|
||||
// see storeDMMsg() for why this matters for synced/queued backlog messages.
|
||||
int addChannelMsg(uint8_t ch_idx, const char* text, uint32_t timestamp = 0) {
|
||||
// Guard against bogus channel indices (e.g. findChannelIdx() returned -1
|
||||
// and was cast to uint8_t → 255). Storing such an entry would burn a ring
|
||||
// slot for a message that no visible channel can ever surface.
|
||||
@@ -698,7 +704,7 @@ public:
|
||||
_hist_head = (_hist_head + 1) % CH_HIST_MAX;
|
||||
}
|
||||
_hist[pos].ch_idx = ch_idx;
|
||||
_hist[pos].timestamp = rtc_clock.getCurrentTime();
|
||||
_hist[pos].timestamp = timestamp ? timestamp : rtc_clock.getCurrentTime();
|
||||
strncpy(_hist[pos].text, text, sizeof(_hist[pos].text) - 1);
|
||||
_hist[pos].text[sizeof(_hist[pos].text) - 1] = '\0';
|
||||
_hist[pos].relay_status = ACK_NONE;
|
||||
|
||||
Reference in New Issue
Block a user