Philipp Hörist pushed to branch master at gajim / gajim
Commits:
ae699c18 by lovetox at 2022-08-21T11:29:53+02:00
refactor: ChatBanner: Use asserts instead of return
There is no case where client or contact should be None
- - - - -
32c0d3e3 by lovetox at 2022-08-21T11:42:29+02:00
refactor: Chatstates: Fix TODOs and refactor checks for different contacts
- Lower logging level to DEBUG
- Don’t send chatstates to unsubscribed contacts
- - - - -
2 changed files:
- gajim/common/modules/chatstates.py
- gajim/gtk/chat_banner.py
Changes:
=====================================
gajim/common/modules/chatstates.py
=====================================
@@ -36,6 +36,8 @@
from gajim.common.const import ClientState
from gajim.common.structs import OutgoingMessage
from gajim.common.modules.base import BaseModule
+from gajim.common.modules.contacts import GroupchatParticipant
+from gajim.common.modules.contacts import BareContact
INACTIVE_AFTER = 60
PAUSED_AFTER = 10
@@ -270,9 +272,9 @@ def set_chatstate(self, contact: types.ChatContactT, state: State) -> None:
if setting == 'disabled':
# Send a last 'active' state after user disabled chatstates
if current_state is not None:
- self._log.info('Disabled for %s', contact.jid)
+ self._log.info('Disabled for %s', contact)
self._log.info('Send last state: %-10s - %s',
- State.ACTIVE, contact.jid)
+ State.ACTIVE, contact)
self._send_chatstate(contact, State.ACTIVE)
@@ -281,22 +283,23 @@ def set_chatstate(self, contact: types.ChatContactT, state: State) -> None:
self._last_keyboard_activity.pop(contact.jid, None)
return
- if not contact.is_groupchat:
- # Don’t leak presence to contacts
- # which are not allowed to see our status
- if not contact.is_pm_contact:
- # TODO
- # if contact and contact.sub in ('to', 'none'):
- # self._log.info('Contact not subscribed: %s', contact.jid)
- # return
- pass
+ if isinstance(contact, BareContact):
+ if not contact.is_subscribed:
+ self._log.debug('Contact not subscribed: %s', contact)
+ return
if not contact.is_available:
- self._log.info('Contact offline: %s', contact.jid)
+ self._log.debug('Contact offline: %s', contact)
return
- if not contact.supports(Namespace.CHATSTATES):
- self._log.info('Chatstates not supported: %s', contact.jid)
+ elif isinstance(contact, GroupchatParticipant):
+ if not contact.is_available:
+ self._log.debug('Contact offline: %s', contact)
+ return
+
+ else:
+ if not contact.is_joined:
+ self._log.debug('Groupchat not joined: %s', contact)
return
if state in (State.ACTIVE, State.COMPOSING):
@@ -309,7 +312,7 @@ def set_chatstate(self, contact: types.ChatContactT, state: State) -> None:
if current_state == state:
return
- self._log.info('Send: %-10s - %s', state, contact.jid)
+ self._log.info('Send: %-10s - %s', state, contact)
self._send_chatstate(contact, state)
=====================================
gajim/gtk/chat_banner.py
=====================================
@@ -240,8 +240,8 @@ def _update_avatar(self) -> None:
self._ui.avatar_image.set_from_surface(surface)
def _update_content(self) -> None:
- if self._client is None or self._contact is None:
- return
+ assert self._contact is not None
+ assert self._client is not None
name = self._contact.name
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/12669c512656b01180a2871f5a8f1b1…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/12669c512656b01180a2871f5a8f1b1…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
12669c51 by lovetox at 2022-08-21T00:28:36+02:00
fix: Don’t reset setting when closing single chat
- confirm_close_muc was reset to False whenever a single chat was closed
- Refactor code
- - - - -
1 changed file:
- gajim/gtk/chat_list_stack.py
Changes:
=====================================
gajim/gtk/chat_list_stack.py
=====================================
@@ -251,31 +251,38 @@ def remove_chat(self, workspace_id: str, account: str, jid: JID) -> None:
chat_list = self._chat_lists[workspace_id]
type_ = chat_list.get_chat_type(account, jid)
- def _leave(is_checked: bool) -> None:
- if is_checked:
+ def _leave(not_ask_again: bool) -> None:
+ if not_ask_again:
app.settings.set('confirm_close_muc', False)
+ _remove()
+ def _remove() -> None:
chat_list.remove_chat(account, jid, emit_unread=False)
self.store_open_chats(workspace_id)
self.emit('chat-removed', account, jid, type_)
- if type_ == 'groupchat' and app.settings.get('confirm_close_muc'):
- client = app.get_client(account)
- contact = client.get_module('Contacts').get_group_chat_contact(jid)
- ConfirmationCheckDialog(
- _('Leave Group Chat'),
- _('Are you sure you want to leave this group chat?'),
- _('If you close this chat, you will leave '
- '"%s".') % contact.name,
- _('_Do not ask me again'),
- [DialogButton.make('Cancel'),
- DialogButton.make('Accept',
- text=_('_Leave'),
- callback=_leave)],
- transient_for=app.window).show()
+ if type_ != 'groupchat' or not app.settings.get('confirm_close_muc'):
+ _remove()
return
- _leave(True)
+ client = app.get_client(account)
+ contact = client.get_module('Contacts').get_group_chat_contact(jid)
+
+ if contact.is_not_joined:
+ _remove()
+ return
+
+ ConfirmationCheckDialog(
+ _('Leave Group Chat'),
+ _('Are you sure you want to leave this group chat?'),
+ _('If you close this chat, you will leave '
+ '"%s".') % contact.name,
+ _('_Do not ask me again'),
+ [DialogButton.make('Cancel'),
+ DialogButton.make('Accept',
+ text=_('_Leave'),
+ callback=_leave)],
+ transient_for=app.window).show()
def remove_chats_for_account(self, account: str) -> None:
for workspace_id, chat_list in self._chat_lists.items():
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/12669c512656b01180a2871f5a8f1b1e…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/12669c512656b01180a2871f5a8f1b1e…
You're receiving this email because of your account on dev.gajim.org.