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


Commits:
bd7b61ed by Nicoco at 2024-05-07T19:06:40+00:00
imprv: Dismiss invitation notification when MUC is joined

- - - - -


1 changed file:

- gajim/gtk/notification_manager.py


Changes:

=====================================
gajim/gtk/notification_manager.py
=====================================
@@ -260,15 +260,16 @@ def add_invitation_received(self, event: MucInvitation) 
-> None:
         if row is not None:
             return
 
-        new_row = InvitationReceivedRow(self._account, event)
-        new_row.connect('destroy', self._on_row_destroy)
-        self.add(new_row)
-        self.update_unread_count()
-
         jid = event.from_.bare
         client = app.get_client(event.account)
         muc_contact = client.get_module('Contacts').get_contact(event.muc)
         assert isinstance(muc_contact, GroupchatContact)
+
+        new_row = InvitationReceivedRow(self._account, event, muc_contact)
+        new_row.connect('destroy', self._on_row_destroy)
+        self.add(new_row)
+        self.update_unread_count()
+
         if (muc_contact.muc_context == 'private' and
                 not event.muc.bare_match(event.from_)):
             contact = self._client.get_module('Contacts').get_contact(jid)
@@ -432,9 +433,13 @@ def _on_dismiss(self, _button: Gtk.Button) -> None:
 
 
 class InvitationReceivedRow(NotificationRow):
-    def __init__(self, account: str, event: MucInvitation) -> None:
+    def __init__(self,
+                 account: str,
+                 event: MucInvitation,
+                 muc_contact: GroupchatContact) -> None:
         NotificationRow.__init__(self, account, str(event.muc))
         self.type = 'invitation-received'
+        muc_contact.connect('room-joined', self._on_room_joined)
 
         self._event = event
 
@@ -447,9 +452,6 @@ def __init__(self, account: str, event: MucInvitation) -> 
None:
         title_label.get_style_context().add_class('bold')
         self.grid.attach(title_label, 2, 1, 1, 1)
 
-        client = app.get_client(event.account)
-        muc_contact = client.get_module('Contacts').get_contact(event.muc)
-        assert isinstance(muc_contact, GroupchatContact)
         if (muc_contact.muc_context == 'private' and
                 not event.muc.bare_match(event.from_)):
             contact = self._client.get_module('Contacts').get_contact(jid)
@@ -492,6 +494,10 @@ def _on_decline_invitation(self, _button: Gtk.Button) -> 
None:
             self.jid, self._event.from_)
         self.destroy()
 
+    def _on_room_joined(self,
+                        contact: GroupchatContact,
+                        signal_name: str) -> None:
+        self.destroy()
 
 class InvitationDeclinedRow(NotificationRow):
     def __init__(self, account: str, event: MucDecline) -> None:



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

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


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to