[fractal] room-history: Use AttachmentDialog async call every time
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] room-history: Use AttachmentDialog async call every time
- Date: Wed, 27 Apr 2022 13:17:44 +0000 (UTC)
commit 854327266eebd654b1650197f3e6c7fee36db58c
Author: Kévin Commaille <zecakeh tedomum fr>
Date: Wed Apr 27 14:34:33 2022 +0200
room-history: Use AttachmentDialog async call every time
Part-of: <https://gitlab.gnome.org/GNOME/fractal/-/merge_requests/1085>
src/session/content/room_history/mod.rs | 46 ++++++++++++---------------------
1 file changed, 16 insertions(+), 30 deletions(-)
---
diff --git a/src/session/content/room_history/mod.rs b/src/session/content/room_history/mod.rs
index b29705d6c..304a2fd94 100644
--- a/src/session/content/room_history/mod.rs
+++ b/src/session/content/room_history/mod.rs
@@ -762,22 +762,17 @@ impl RoomHistory {
let filename = filename_for_mime(Some(mime::IMAGE_PNG.as_ref()), None);
let dialog = AttachmentDialog::for_image(&window, &filename, &image);
- dialog.connect_local(
- "send",
- false,
- clone!(@weak self as obj, @strong image => @default-return None, move |_| {
- if let Some(room) = obj.room() {
- room.send_attachment(
- image.save_to_png_bytes().to_vec(),
- mime::IMAGE_PNG,
- &filename,
- );
- }
+ if dialog.run_future().await != gtk::ResponseType::Ok {
+ return;
+ }
- None
- }),
- );
- dialog.present();
+ if let Some(room) = self.room() {
+ room.send_attachment(
+ image.save_to_png_bytes().to_vec(),
+ mime::IMAGE_PNG,
+ &filename,
+ );
+ }
}
pub fn select_file(&self) {
@@ -838,22 +833,13 @@ impl RoomHistory {
let window = self.root().unwrap().downcast::<gtk::Window>().unwrap();
let dialog = AttachmentDialog::for_file(&window, &filename, &file);
- dialog.connect_local(
- "send",
- false,
- clone!(@weak self as obj => @default-return None, move |_| {
- if let Some(room) = obj.room() {
- room.send_attachment(
- bytes.clone(),
- mime.clone(),
- &filename,
- );
- }
+ if dialog.run_future().await != gtk::ResponseType::Ok {
+ return;
+ }
- None
- }),
- );
- dialog.present();
+ if let Some(room) = self.room() {
+ room.send_attachment(bytes.clone(), mime.clone(), &filename);
+ }
}
Err(err) => {
warn!("Could not read file: {}", err);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]