aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_view_controller.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-07-03 21:14:39 +0200
committerfiaxh <git@lightrise.org>2020-07-16 23:31:19 +0200
commite159fd2492c28c1ef4ab64828ca0e8c2de877b41 (patch)
treeaca3c42854b08b5683a1c85e7c7a74fd0a4bdf0d /main/src/ui/conversation_view_controller.vala
parent74f7fa897f9aec298eeadcfc7a7b971f06498858 (diff)
downloaddino-e159fd2492c28c1ef4ab64828ca0e8c2de877b41.tar.gz
dino-e159fd2492c28c1ef4ab64828ca0e8c2de877b41.zip
Only query entity caps when we need them
Diffstat (limited to 'main/src/ui/conversation_view_controller.vala')
-rw-r--r--main/src/ui/conversation_view_controller.vala47
1 files changed, 27 insertions, 20 deletions
diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala
index 831aae73..b2be8ed8 100644
--- a/main/src/ui/conversation_view_controller.vala
+++ b/main/src/ui/conversation_view_controller.vala
@@ -93,9 +93,12 @@ public class ConversationViewController : Object {
AccelGroup accel_group = new AccelGroup();
accel_group.connect(Gdk.Key.U, ModifierType.CONTROL_MASK, AccelFlags.VISIBLE, () => {
- if (conversation != null && stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation)) {
- open_file_picker();
- }
+ if (conversation == null) return false;
+ stream_interactor.get_module(FileManager.IDENTITY).is_upload_available.begin(conversation, (_, res) => {
+ if (stream_interactor.get_module(FileManager.IDENTITY).is_upload_available.end(res)) {
+ open_file_picker();
+ }
+ });
return false;
});
((Gtk.Window)view.get_toplevel()).add_accel_group(accel_group);
@@ -138,13 +141,15 @@ public class ConversationViewController : Object {
}
private void update_file_upload_status() {
- bool upload_available = stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation);
- chat_input_controller.set_file_upload_active(upload_available);
- if (upload_available && overlay_dialog == null) {
- Gtk.drag_dest_set(view, DestDefaults.ALL, target_list, Gdk.DragAction.COPY);
- } else {
- Gtk.drag_dest_unset(view);
- }
+ stream_interactor.get_module(FileManager.IDENTITY).is_upload_available.begin(conversation, (_, res) => {
+ bool upload_available = stream_interactor.get_module(FileManager.IDENTITY).is_upload_available.end(res);
+ chat_input_controller.set_file_upload_active(upload_available);
+ if (upload_available && overlay_dialog == null) {
+ Gtk.drag_dest_set(view, DestDefaults.ALL, target_list, Gdk.DragAction.COPY);
+ } else {
+ Gtk.drag_dest_unset(view);
+ }
+ });
}
private void update_conversation_display_name() {
@@ -212,18 +217,20 @@ public class ConversationViewController : Object {
FileSendOverlay overlay = new FileSendOverlay(file, file_info);
overlay.send_file.connect(() => send_file(file));
- HashMap<int, long> limits = stream_interactor.get_module(FileManager.IDENTITY).get_file_size_limits(conversation);
- bool something_works = false;
- foreach (var limit in limits.values) {
- if (limit >= file_info.get_size()) {
- something_works = true;
+ stream_interactor.get_module(FileManager.IDENTITY).get_file_size_limits.begin(conversation, (_, res) => {
+ HashMap<int, long> limits = stream_interactor.get_module(FileManager.IDENTITY).get_file_size_limits.end(res);
+ bool something_works = false;
+ foreach (var limit in limits.values) {
+ if (limit >= file_info.get_size()) {
+ something_works = true;
+ }
}
- }
- if (!something_works && limits.has_key(0)) {
- if (!something_works && file_info.get_size() > limits[0]) {
- overlay.set_file_too_large();
+ if (!something_works && limits.has_key(0)) {
+ if (!something_works && file_info.get_size() > limits[0]) {
+ overlay.set_file_too_large();
+ }
}
- }
+ });
overlay.close.connect(() => {
// We don't want drag'n'drop to be active while the overlay is active