Philipp Hörist pushed to branch master at gajim / gajim


Commits:
b543f1ab by lovetox at 2021-02-17T22:05:26+01:00
Profile: Show error if avatar upload fails

- - - - -


1 changed file:

- gajim/gtk/profile.py


Changes:

=====================================
gajim/gtk/profile.py
=====================================
@@ -236,8 +236,10 @@ def _on_save_clicked(self, _widget):
 
         else:
             # Only update avatar if it changed
-            con.get_module('UserAvatar').set_avatar(self._new_avatar,
-                                                    public=public)
+            con.get_module('UserAvatar').set_avatar(
+                self._new_avatar,
+                public=public,
+                callback=self._on_set_avatar)
 
         nick = GLib.markup_escape_text(self._ui.nickname_entry.get_text())
         con.get_module('UserNickname').set_nickname(nick, public=public)
@@ -247,6 +249,28 @@ def _on_save_clicked(self, _widget):
                 self.account, 'name')
         app.nicks[self.account] = nick
 
+    def _on_set_avatar(self, task):
+        try:
+            task.finish()
+        except StanzaError as error:
+            if self._new_avatar is None:
+                # Trying to remove the avatar but the node does not exist
+                if error.condition == 'item-not-found':
+                    return
+
+            title = _('Error while uploading avatar')
+            text = error.get_text()
+
+            if (error.condition == 'not-acceptable' and
+                    error.app_condition == 'payload-too-big'):
+                text = _('Avatar file size too big')
+
+            ErrorDialog(title, text)
+
+            self._ui.avatar_image.set_from_surface(self._current_avatar)
+            self._new_avatar = False
+            return
+
     def _on_remove_avatar(self, _button):
         contact = app.contacts.create_contact(self._jid, self.account)
         scale = self.get_scale_factor()



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/b543f1ab31b022bb5e1326a25486401fa77d19a4

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/b543f1ab31b022bb5e1326a25486401fa77d19a4
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to