update room kind on new message
This commit is contained in:
@@ -613,9 +613,19 @@ impl ChatRegistry {
|
|||||||
/// If the room doesn't exist, it will be created.
|
/// If the room doesn't exist, it will be created.
|
||||||
/// Updates room ordering based on the most recent messages.
|
/// Updates room ordering based on the most recent messages.
|
||||||
pub fn new_message(&mut self, message: NewMessage, cx: &mut Context<Self>) {
|
pub fn new_message(&mut self, message: NewMessage, cx: &mut Context<Self>) {
|
||||||
|
let nostr = NostrRegistry::global(cx);
|
||||||
|
let signer = nostr.read(cx).signer();
|
||||||
|
|
||||||
match self.rooms.iter().find(|e| e.read(cx).id == message.room) {
|
match self.rooms.iter().find(|e| e.read(cx).id == message.room) {
|
||||||
Some(room) => {
|
Some(room) => {
|
||||||
room.update(cx, |this, cx| {
|
room.update(cx, |this, cx| {
|
||||||
|
if this.kind == RoomKind::Request {
|
||||||
|
if let Some(public_key) = signer.public_key() {
|
||||||
|
if message.rumor.pubkey == public_key {
|
||||||
|
this.set_ongoing(cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
this.push_message(message, cx);
|
this.push_message(message, cx);
|
||||||
});
|
});
|
||||||
self.sort(cx);
|
self.sort(cx);
|
||||||
|
|||||||
@@ -57,7 +57,11 @@ impl SendReport {
|
|||||||
|
|
||||||
/// Returns true if the send is pending.
|
/// Returns true if the send is pending.
|
||||||
pub fn pending(&self) -> bool {
|
pub fn pending(&self) -> bool {
|
||||||
self.output.is_none() && self.error.is_none()
|
self.error.is_none()
|
||||||
|
&& self
|
||||||
|
.output
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|o| o.success.is_empty() && o.failed.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the send was successful.
|
/// Returns true if the send was successful.
|
||||||
@@ -228,10 +232,8 @@ impl Room {
|
|||||||
|
|
||||||
/// Sets this room is ongoing conversation
|
/// Sets this room is ongoing conversation
|
||||||
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
|
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
|
||||||
if self.kind != RoomKind::Ongoing {
|
self.kind = RoomKind::Ongoing;
|
||||||
self.kind = RoomKind::Ongoing;
|
cx.notify();
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the creation timestamp of the room
|
/// Updates the creation timestamp of the room
|
||||||
|
|||||||
Reference in New Issue
Block a user