fix unread count: sent messages don't count as unread

Track outgoing messages separately (own counter) so they appear
in the log but don't inflate unread counts. Reset on recv.

Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-04-03 20:42:36 -04:00
parent e104a16f61
commit 53a2dbac37
3 changed files with 22 additions and 5 deletions

View file

@ -544,7 +544,10 @@ impl channel_server::Server for ChannelServerImpl {
} else {
format!("[PM:{}] {}", target, message)
};
state.borrow_mut().push_message(log_line, 0, &channel);
state.borrow_mut().channel_logs
.entry(channel.clone())
.or_insert_with(ChannelLog::new)
.push_own(log_line);
Ok(())
})

View file

@ -260,9 +260,13 @@ impl channel_server::Server for ChannelServerImpl {
let ts = now() as u64;
append_history(&format!("{ts} [agent] {message}"));
state.borrow_mut().push_message(
format!("[agent] {}", message), 0, "telegram.agent"
);
{
let channel = "telegram.agent".to_string();
state.borrow_mut().channel_logs
.entry(channel)
.or_insert_with(ChannelLog::new)
.push_own(format!("[agent] {}", message));
}
Ok(())
})
}