Add the ability to reply to a message (#7170)

Feature
- [x] Allow to click on reply to go to the real message
    - [x] In chat
- [x] Show only a part of the message that you reply to
    - [x] In chat
    - [x] In reply preview

TODO’s
- [x] Fix migration
    - [x] timestamp(in filename)
    - [x] remove the reference to the reply_message_id
- [x] Fix markdown cache for reply message
- [x] Fix spacing when first message is a reply to you and you want to
reply to that message.
- [x] Fetch message that you replied to
    - [x] allow fetching messages that are not inside the current view 
- [x] When message is deleted, we should show a text like `message
deleted` or something
    - [x] Show correct GitHub username + icon after `Replied to: `
    - [x] Show correct message(now it's hard-coded)
- [x] Add icon to reply + add the onClick logic
- [x] Show message that you want to reply to
  - [x] Allow to click away the message that you want to reply to
  - [x] Fix hard-coded GitHub user + icon after `Reply tp:`
  - [x] Add tests

<img width="242" alt="Screenshot 2024-02-06 at 20 51 40"
src="https://github.com/zed-industries/zed/assets/62463826/a7a5f3e0-dee3-4d38-95db-258b169e4498">
<img width="240" alt="Screenshot 2024-02-06 at 20 52 02"
src="https://github.com/zed-industries/zed/assets/62463826/3e136de3-4135-4c07-bd43-30089b677c0a">


Release Notes:

- Added the ability to reply to a message.
- Added highlight message when you click on mention notifications or a
reply message.

---------

Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Remco Smits 2024-02-06 21:22:54 +01:00 committed by GitHub
parent 743f9b345f
commit 6c4b96ec76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 568 additions and 109 deletions

View file

@ -34,6 +34,7 @@ pub struct MessageEditor {
mentions: Vec<UserId>,
mentions_task: Option<Task<()>>,
channel_id: Option<ChannelId>,
reply_to_message_id: Option<u64>,
}
struct MessageEditorCompletionProvider(WeakView<MessageEditor>);
@ -112,9 +113,22 @@ impl MessageEditor {
channel_id: None,
mentions: Vec::new(),
mentions_task: None,
reply_to_message_id: None,
}
}
pub fn reply_to_message_id(&self) -> Option<u64> {
self.reply_to_message_id
}
pub fn set_reply_to_message_id(&mut self, reply_to_message_id: u64) {
self.reply_to_message_id = Some(reply_to_message_id);
}
pub fn clear_reply_to_message_id(&mut self) {
self.reply_to_message_id = None;
}
pub fn set_channel(
&mut self,
channel_id: u64,
@ -172,8 +186,13 @@ impl MessageEditor {
editor.clear(cx);
self.mentions.clear();
let reply_to_message_id = std::mem::take(&mut self.reply_to_message_id);
MessageParams { text, mentions }
MessageParams {
text,
mentions,
reply_to_message_id,
}
})
}
@ -424,6 +443,7 @@ mod tests {
MessageParams {
text,
mentions: vec![(ranges[0].clone(), 101), (ranges[1].clone(), 102)],
reply_to_message_id: None
}
);
});