Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
c229ed1a by wurstsalat at 2024-06-03T22:07:19+02:00
cfix: Reactions: Improve action visibility/state toggling
Hide/disable reaction actions if conditions are not met
Fixes #11853
- - - - -
2 changed files:
- gajim/gtk/conversation/reactions_bar.py
- gajim/gtk/conversation/rows/widgets.py
Changes:
=====================================
gajim/gtk/conversation/reactions_bar.py
=====================================
@@ -4,6 +4,7 @@
from __future__ import annotations
+from typing import Any
from typing import NamedTuple
from typing import TYPE_CHECKING
@@ -18,6 +19,7 @@
from gajim.common import types
from gajim.common.i18n import _
from gajim.common.modules.contacts import BareContact
+from gajim.common.modules.contacts import GroupchatContact
from gajim.common.storage.archive import models as mod
from gajim.common.storage.archive.const import ChatDirection
@@ -42,6 +44,12 @@ def __init__(self, message_row: MessageRow, contact:
types.ChatContactT) -> None
Gtk.Box.__init__(self, spacing=3, no_show_all=True,
halign=Gtk.Align.START)
self._message_row = message_row
self._contact = contact
+ if isinstance(self._contact, GroupchatContact):
+ self._contact.connect('state-changed', self._on_muc_state_changed)
+
+ self._client = app.get_client(self._contact.account)
+ self._client.connect_signal('state-changed',
self._on_client_state_changed)
+ self.set_sensitive(self._get_reactions_enabled())
self._reactions: list[mod.Reaction] = []
@@ -51,6 +59,27 @@ def __init__(self, message_row: MessageRow, contact:
types.ChatContactT) -> None
add_reaction_button.connect('emoji-added', self._on_emoji_added)
self.pack_end(add_reaction_button, False, False, 0)
+ def _on_client_state_changed(self, *args: Any) -> None:
+ self.set_sensitive(self._get_reactions_enabled())
+
+ def _on_muc_state_changed(self, *args: Any) -> None:
+ self.set_sensitive(self._get_reactions_enabled())
+
+ def _get_reactions_enabled(self) -> bool:
+ if not app.account_is_connected(self._contact.account):
+ return False
+
+ if isinstance(self._contact, GroupchatContact):
+ if not self._contact.is_joined:
+ return False
+
+ self_contact = self._contact.get_self()
+ assert self_contact is not None
+ if self_contact.role.is_visitor:
+ return False
+
+ return True
+
def _aggregate_reactions(
self, reactions: list[mod.Reaction]
) -> dict[str, list[ReactionData]]:
=====================================
gajim/gtk/conversation/rows/widgets.py
=====================================
@@ -156,13 +156,26 @@ def _get_reply_visible(self) -> bool:
def _get_reactions_visible(self) -> bool:
assert self._message_row is not None
+ assert self._contact is not None
+
+ if not app.account_is_connected(self._contact.account):
+ return False
if isinstance(self._contact, GroupchatContact):
+ if not self._contact.is_joined:
+ return False
+
+ self_contact = self._contact.get_self()
+ assert self_contact is not None
+ if self_contact.role.is_visitor:
+ return False
+
if self._message_row.stanza_id is None:
return False
if self._contact.muc_context == 'public':
return self._contact.supports(Namespace.OCCUPANT_ID)
+
return True
return self._message_row.message_id is not None
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/c229ed1a2404c6880e0279773ee6af4e754efba4
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/c229ed1a2404c6880e0279773ee6af4e754efba4
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]