mirror of
https://github.com/ratspeak/ratdeck.git
synced 2026-10-23 01:41:17 +00:00
v1.5.4: Hop-based eviction, first-boot data cleanup, message performance
- Evict highest-hop unsaved nodes first when peer list is full (nearby peers survive) - Add first-boot SD data cleanup screen before name input - Conversation summaries cache for faster message list rendering - Optimize message view refresh with summary-based change detection - Streamline unread tracking through MessageStore instead of LXMFManager
This commit is contained in:
1 parent
76b03a7508
commit
1e22924159
15 files changed
+418
-73
No files matched your search
@@ -146,8 +146,6 @@ void LXMFManager::processIncoming(const uint8_t* data, size_t len, const RNS::By
|
||||
Serial.printf("[LXMF] Message from %s (%d bytes) content_len=%d\n",
|
||||
msg.sourceHash.toHex().substr(0, 8).c_str(), (int)len, (int)msg.content.size());
|
||||
if (_store) { _store->saveMessage(msg); }
|
||||
std::string peerHex = msg.sourceHash.toHex();
|
||||
_unread[peerHex]++;
|
||||
if (_onMessage) { _onMessage(msg); }
|
||||
}
|
||||
|
||||
@@ -163,28 +161,17 @@ std::vector<LXMFMessage> LXMFManager::getMessages(const std::string& peerHex) co
|
||||
}
|
||||
|
||||
int LXMFManager::unreadCount(const std::string& peerHex) const {
|
||||
if (!_unreadComputed) { const_cast<LXMFManager*>(this)->computeUnreadFromDisk(); }
|
||||
if (peerHex.empty()) {
|
||||
int total = 0;
|
||||
for (auto& kv : _unread) total += kv.second;
|
||||
return total;
|
||||
}
|
||||
auto it = _unread.find(peerHex);
|
||||
return (it != _unread.end()) ? it->second : 0;
|
||||
if (!_store) return 0;
|
||||
if (peerHex.empty()) return _store->totalUnreadCount();
|
||||
const ConversationSummary* s = _store->getSummary(peerHex);
|
||||
return s ? s->unreadCount : 0;
|
||||
}
|
||||
|
||||
void LXMFManager::computeUnreadFromDisk() {
|
||||
_unreadComputed = true;
|
||||
if (!_store) return;
|
||||
for (auto& conv : _store->conversations()) {
|
||||
auto msgs = _store->loadConversation(conv);
|
||||
int count = 0;
|
||||
for (auto& m : msgs) { if (m.incoming && !m.read) count++; }
|
||||
if (count > 0) _unread[conv] = count;
|
||||
}
|
||||
const ConversationSummary* LXMFManager::getConversationSummary(const std::string& peerHex) const {
|
||||
if (!_store) return nullptr;
|
||||
return _store->getSummary(peerHex);
|
||||
}
|
||||
|
||||
void LXMFManager::markRead(const std::string& peerHex) {
|
||||
_unread[peerHex] = 0;
|
||||
if (_store) { _store->markConversationRead(peerHex); }
|
||||
}
|
||||
Reference in new issue
Block a user