Trunk fixes

This commit is contained in:
HarukiToreda
2025-10-12 16:34:59 -04:00
parent 50a65a1393
commit 551086324b
3 changed files with 20 additions and 16 deletions

View File

@@ -269,8 +269,7 @@ void MessageStore::clearAllMessages()
}
// Internal helper: erase first or last message matching a predicate
template <typename Predicate>
static void eraseIf(std::deque<StoredMessage> &deque, Predicate pred, bool fromBack = false)
template <typename Predicate> static void eraseIf(std::deque<StoredMessage> &deque, Predicate pred, bool fromBack = false)
{
if (fromBack) {
// Iterate from the back and erase the first match from the end
@@ -299,9 +298,7 @@ void MessageStore::dismissOldestMessage()
// Dismiss oldest message in a specific channel
void MessageStore::dismissOldestMessageInChannel(uint8_t channel)
{
auto pred = [channel](const StoredMessage &m) {
return m.type == MessageType::BROADCAST && m.channelIndex == channel;
};
auto pred = [channel](const StoredMessage &m) { return m.type == MessageType::BROADCAST && m.channelIndex == channel; };
eraseIf(liveMessages, pred);
eraseIf(messages, pred);
saveToFlash();
@@ -325,8 +322,10 @@ void MessageStore::dismissOldestMessageWithPeer(uint32_t peer)
// Dismiss newest message (RAM + persisted queue)
void MessageStore::dismissNewestMessage()
{
eraseIf(liveMessages, [](StoredMessage &) { return true; }, true);
eraseIf(messages, [](StoredMessage &) { return true; }, true);
eraseIf(
liveMessages, [](StoredMessage &) { return true; }, true);
eraseIf(
messages, [](StoredMessage &) { return true; }, true);
saveToFlash();
}

View File

@@ -36,10 +36,14 @@ static std::vector<std::string> cachedLines;
static std::vector<int> cachedHeights;
// UTF-8 skip helper
inline size_t utf8CharLen(uint8_t c) {
if ((c & 0xE0) == 0xC0) return 2;
if ((c & 0xF0) == 0xE0) return 3;
if ((c & 0xF8) == 0xF0) return 4;
inline size_t utf8CharLen(uint8_t c)
{
if ((c & 0xE0) == 0xC0)
return 2;
if ((c & 0xF0) == 0xE0)
return 3;
if ((c & 0xF8) == 0xF0)
return 4;
return 1;
}
@@ -229,7 +233,8 @@ const std::vector<uint32_t> &getSeenPeers()
return seenPeers;
}
inline int centerYForRow(int y, int size) {
inline int centerYForRow(int y, int size)
{
int midY = y + (FONT_HEIGHT_SMALL / 2);
return midY - (size / 2);
}