Add an indicator to the channel chat to see all the messages that you missed (#7781)
This pull requests add the following features: - Show indicator before first unseen message - Scroll to last unseen message <img width="241" alt="Screenshot 2024-02-14 at 18 10 35" src="https://github.com/zed-industries/zed/assets/62463826/ca396daf-7102-4eac-ae50-7d0b5ba9b6d5"> https://github.com/zed-industries/zed/assets/62463826/3a5c4afb-aea7-4e7b-98f6-515c027ef83b ### Questions: 1. Should we hide the indicator after a couple of seconds? Now the indicator will hide when you close/reopen the channel chat, because when the last unseen channel message ID is not smaller than the last message we will not show it. Release Notes: - Added unseen messages indicator for the channel chat.
This commit is contained in:
parent
0422d43798
commit
aad7761038
2 changed files with 180 additions and 123 deletions
|
@ -348,6 +348,21 @@ impl ChannelStore {
|
|||
.is_some_and(|state| state.has_new_messages())
|
||||
}
|
||||
|
||||
pub fn last_acknowledge_message_id(&self, channel_id: ChannelId) -> Option<u64> {
|
||||
self.channel_states.get(&channel_id).and_then(|state| {
|
||||
if let Some(last_message_id) = state.latest_chat_message {
|
||||
if state
|
||||
.last_acknowledged_message_id()
|
||||
.is_some_and(|id| id < last_message_id)
|
||||
{
|
||||
return state.last_acknowledged_message_id();
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
pub fn acknowledge_message_id(
|
||||
&mut self,
|
||||
channel_id: ChannelId,
|
||||
|
@ -1152,6 +1167,10 @@ impl ChannelState {
|
|||
})
|
||||
}
|
||||
|
||||
fn last_acknowledged_message_id(&self) -> Option<u64> {
|
||||
self.observed_chat_message
|
||||
}
|
||||
|
||||
fn acknowledge_message_id(&mut self, message_id: u64) {
|
||||
let observed = self.observed_chat_message.get_or_insert(message_id);
|
||||
*observed = (*observed).max(message_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue