diff options
author | fiaxh <git@lightrise.org> | 2019-04-19 21:42:40 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-04-24 23:44:00 +0200 |
commit | b6799e59bb9cc2ea511b0f19aab88a83c244dda8 (patch) | |
tree | 5eb981539bd97e6e5a46d47b4869fb51cf561dc6 /main/src/ui/notifications.vala | |
parent | cbe0ff2c1d6eb86520fdba05183f33cd4f262bcd (diff) | |
download | dino-b6799e59bb9cc2ea511b0f19aab88a83c244dda8.tar.gz dino-b6799e59bb9cc2ea511b0f19aab88a83c244dda8.zip |
Remove avatars with missmatch between supposed and actual sha1 hash on load, make loading async
Diffstat (limited to 'main/src/ui/notifications.vala')
-rw-r--r-- | main/src/ui/notifications.vala | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala index 277a7a09..fe545154 100644 --- a/main/src/ui/notifications.vala +++ b/main/src/ui/notifications.vala @@ -41,12 +41,12 @@ public class Notifications : Object { } public void start() { - stream_interactor.get_module(NotificationEvents.IDENTITY).notify_content_item.connect(notify_content_item); + stream_interactor.get_module(NotificationEvents.IDENTITY).notify_content_item.connect((content_item, conversation) => notify_content_item.begin(content_item, conversation)); stream_interactor.get_module(NotificationEvents.IDENTITY).notify_subscription_request.connect(notify_subscription_request); stream_interactor.get_module(NotificationEvents.IDENTITY).notify_connection_error.connect(notify_connection_error); } - private void notify_content_item(ContentItem content_item, Conversation conversation) { + private async void notify_content_item(ContentItem content_item, Conversation conversation) { if (!notifications.has_key(conversation)) { notifications[conversation] = new Notification(""); notifications[conversation].set_default_action_and_target_value("app.open-conversation", new Variant.int32(conversation.id)); @@ -77,18 +77,20 @@ public class Notifications : Object { notifications[conversation].set_title(display_name); notifications[conversation].set_body(text); try { - notifications[conversation].set_icon(get_pixbuf_icon((new AvatarGenerator(40, 40)).draw_conversation(stream_interactor, conversation))); + Cairo.ImageSurface conversation_avatar = yield (new AvatarGenerator(40, 40)).draw_conversation(stream_interactor, conversation); + notifications[conversation].set_icon(get_pixbuf_icon(conversation_avatar)); } catch (Error e) { } window.get_application().send_notification(conversation.id.to_string(), notifications[conversation]); active_conversation_ids.add(conversation.id.to_string()); window.urgency_hint = true; } - private void notify_subscription_request(Conversation conversation) { + private async void notify_subscription_request(Conversation conversation) { Notification notification = new Notification(_("Subscription request")); notification.set_body(conversation.counterpart.to_string()); try { - notification.set_icon(get_pixbuf_icon((new AvatarGenerator(40, 40)).draw_jid(stream_interactor, conversation.counterpart, conversation.account))); + Cairo.ImageSurface jid_avatar = yield (new AvatarGenerator(40, 40)).draw_jid(stream_interactor, conversation.counterpart, conversation.account); + notification.set_icon(get_pixbuf_icon(jid_avatar)); } catch (Error e) { } notification.set_default_action_and_target_value("app.open-conversation", new Variant.int32(conversation.id)); notification.add_button_with_target_value(_("Accept"), "app.accept-subscription", conversation.id); |