Messages sent quickly keep their order
Browse files at this commitf3c3e9583232eb4d6e19e399f4c12d82c4f5a4beParent: ae944e7- fix
- messages sent quickly keep their order
3 changed files +6 -0
- crates/client/src/gui.rs +2 -0
- crates/client/src/gui/composer.rs +2 -0
- crates/client/src/gui/voice_note.rs +2 -0
crates/client/src/gui.rsmodified+2 -0
| @@ -587,6 +587,7 @@ pub struct Yumush { | |||
| 587 | backups: Vec<BackupInfo>, | 587 | backups: Vec<BackupInfo>, |
| 588 | pending_backup_delete: Option<String>, | 588 | pending_backup_delete: Option<String>, |
| 589 | share_apps: Vec<crate::share::audio::AudioApp>, | 589 | share_apps: Vec<crate::share::audio::AudioApp>, |
| 590 | + send_order: Arc<tokio::sync::Mutex<()>>, | ||
| 590 | } | 591 | } |
| 591 | 592 | ||
| 592 | impl Yumush { | 593 | impl Yumush { |
| @@ -645,6 +646,7 @@ impl Yumush { | |||
| 645 | backups: Vec::new(), | 646 | backups: Vec::new(), |
| 646 | pending_backup_delete: None, | 647 | pending_backup_delete: None, |
| 647 | share_apps: Vec::new(), | 648 | share_apps: Vec::new(), |
| 649 | + send_order: Default::default(), | ||
| 648 | }; | 650 | }; |
| 649 | yumush.chat.camera_task = Some(camera_view::ticker(cx)); | 651 | yumush.chat.camera_task = Some(camera_view::ticker(cx)); |
| 650 | yumush | 652 | yumush |
crates/client/src/gui/composer.rsmodified+2 -0
| @@ -266,9 +266,11 @@ impl Yumush { | |||
| 266 | let network = self.network.clone(); | 266 | let network = self.network.clone(); |
| 267 | let restore = input.clone(); | 267 | let restore = input.clone(); |
| 268 | let pending = self.chat.media.pending.clone(); | 268 | let pending = self.chat.media.pending.clone(); |
| 269 | + let order = self.send_order.clone(); | ||
| 269 | self.chat.drafts.remove(&community_id); | 270 | self.chat.drafts.remove(&community_id); |
| 270 | 271 | ||
| 271 | cx.spawn_in(window, async move |this, cx| { | 272 | cx.spawn_in(window, async move |this, cx| { |
| 273 | + let _turn = order.lock().await; | ||
| 272 | match network | 274 | match network |
| 273 | .call(CreateMessage { | 275 | .call(CreateMessage { |
| 274 | community_id, | 276 | community_id, |
crates/client/src/gui/voice_note.rsmodified+2 -0
| @@ -267,6 +267,7 @@ impl Yumush { | |||
| 267 | .map(|settings| settings.max_attachment_bytes); | 267 | .map(|settings| settings.max_attachment_bytes); |
| 268 | cx.notify(); | 268 | cx.notify(); |
| 269 | 269 | ||
| 270 | + let order = self.send_order.clone(); | ||
| 270 | cx.spawn_in(window, async move |this, cx| { | 271 | cx.spawn_in(window, async move |this, cx| { |
| 271 | let Some(path) = cx | 272 | let Some(path) = cx |
| 272 | .background_executor() | 273 | .background_executor() |
| @@ -282,6 +283,7 @@ impl Yumush { | |||
| 282 | Ok(attachment) => attachment, | 283 | Ok(attachment) => attachment, |
| 283 | Err(error) => return notify_error(&this, cx, error), | 284 | Err(error) => return notify_error(&this, cx, error), |
| 284 | }; | 285 | }; |
| 286 | + let _turn = order.lock().await; | ||
| 285 | ok_or_notify( | 287 | ok_or_notify( |
| 286 | network | 288 | network |
| 287 | .call(CreateMessage { | 289 | .call(CreateMessage { |