Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits:
3213b5c8 by lovetox at 2021-03-06T16:30:30+01:00
Roster: Fix removing contact
- - - - -
3 changed files:
- gajim/common/modules/roster.py
- gajim/gtk/main.py
- gajim/gtk/roster.py
Changes:
=====================================
gajim/common/modules/roster.py
=====================================
@@ -116,7 +116,10 @@ def _process_roster_push(self, _con, _stanza, properties):
self._log.info('Push received')
item = properties.roster.item
- self._roster[item.jid] = item
+ if item.subscription == 'remove':
+ self._roster.pop(item.jid)
+ else:
+ self._roster[item.jid] = item
self._store_roster()
=====================================
gajim/gtk/main.py
=====================================
@@ -522,18 +522,18 @@ def _block_contact(report=None):
modal=False).show()
def remove_contact(self, account, jid):
+ client = app.get_client(account)
+
def _remove_contact():
self.remove_chat(account, jid)
- roster = self._account_pages[account].get_roster()
- roster.remove_contact(jid)
+ client.get_module('Roster').delete_item(jid)
- client = app.get_client(account)
contact = client.get_module('Contacts').get_contact(jid)
sec_text = _('You are about to remove %(name)s (%(jid)s) from '
'your contact list.\n') % {
'name': contact.name,
'jid': jid}
- # TODO: ConfirmationCheckDialog for subscription decision?
+
ConfirmationDialog(
_('Remove Contact'),
_('Remove contact from contact list'),
=====================================
gajim/gtk/roster.py
=====================================
@@ -26,10 +26,7 @@
log = logging.getLogger('gajim.gui.roster')
-HANDLED_EVENTS = [
- 'presence-received',
-]
-
+HANDLED_EVENTS = []
DEFAULT_GROUP = _('Contacts')
@@ -354,7 +351,11 @@ def _on_roster_received(self, _event):
@event_filter(['account'])
def _on_roster_push(self, event):
contact = self._get_contact(event.item.jid)
- self._add_or_update_contact(contact)
+
+ if event.item.subscription == 'remove':
+ self._remove_contact(contact)
+ else:
+ self._add_or_update_contact(contact)
def _get_current_groups(self, jid):
groups = set()
@@ -560,18 +561,10 @@ def clear(self):
self._group_refs = {}
self._store.clear()
- def _on_presence_received(self, _event):
- pass
-
def process_event(self, event):
if event.name not in HANDLED_EVENTS:
return
- if event.name == 'presence-received':
- self._on_presence_received(event)
- else:
- log.warning('Unhandled Event: %s', event.name)
-
def _on_destroy(self, _roster):
self._remove_actions()
self._contact_refs = {}
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3213b5c8ae2e5d1368e4af5d77c7b3b5002ab0c1
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3213b5c8ae2e5d1368e4af5d77c7b3b5002ab0c1
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