Fix mention notifications are not updated after message change and not removed after a message is deleted (#9847)
@ConradIrwin This is a followup for #9035 as agreed. Release Notes: - Fixed mention notifications are updated when channel message is updated. And mention notifications are removed when message is removed. --------- Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
This commit is contained in:
parent
fe7b12c444
commit
754547f349
8 changed files with 297 additions and 24 deletions
|
@ -114,6 +114,7 @@ impl NotificationStore {
|
|||
_subscriptions: vec![
|
||||
client.add_message_handler(cx.weak_model(), Self::handle_new_notification),
|
||||
client.add_message_handler(cx.weak_model(), Self::handle_delete_notification),
|
||||
client.add_message_handler(cx.weak_model(), Self::handle_update_notification),
|
||||
],
|
||||
user_store,
|
||||
client,
|
||||
|
@ -236,6 +237,40 @@ impl NotificationStore {
|
|||
})?
|
||||
}
|
||||
|
||||
async fn handle_update_notification(
|
||||
this: Model<Self>,
|
||||
envelope: TypedEnvelope<proto::UpdateNotification>,
|
||||
_: Arc<Client>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<()> {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
if let Some(notification) = envelope.payload.notification {
|
||||
if let Some(rpc::Notification::ChannelMessageMention {
|
||||
message_id,
|
||||
sender_id: _,
|
||||
channel_id: _,
|
||||
}) = Notification::from_proto(¬ification)
|
||||
{
|
||||
let fetch_message_task = this.channel_store.update(cx, |this, cx| {
|
||||
this.fetch_channel_messages(vec![message_id], cx)
|
||||
});
|
||||
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
let messages = fetch_message_task.await?;
|
||||
this.update(&mut cx, move |this, cx| {
|
||||
for message in messages {
|
||||
this.channel_messages.insert(message_id, message);
|
||||
}
|
||||
cx.notify();
|
||||
})
|
||||
})
|
||||
.detach_and_log_err(cx)
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})?
|
||||
}
|
||||
|
||||
async fn add_notifications(
|
||||
this: Model<Self>,
|
||||
notifications: Vec<proto::Notification>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue