Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
fd7d7606 by wurstsalat at 2023-11-04T23:59:47+01:00
fix: Message row menu: Show quote and copy actions only if there is text

Fixes #11652

- - - - -


1 changed file:

- gajim/gtk/menus.py


Changes:

=====================================
gajim/gtk/menus.py
=====================================
@@ -688,37 +688,40 @@ def get_chat_row_menu(contact: types.ChatContactT,
 
     menu_items: MenuItemListT = []
 
-    format_string = app.settings.get('date_time_format')
-    timestamp_formatted = timestamp.strftime(format_string)
+    if text:
+        # Text can be an empty string,
+        # e.g. if a preview has not been loaded yet
+        timestamp_formatted = timestamp.strftime(
+            app.settings.get('date_time_format'))
+
+        copy_text = f'{timestamp_formatted} - {name}: '
+        if text.startswith(('```', '> ')):
+            # Prepend a line break in order to keep code block/quotes rendering
+            copy_text += '\n'
+        copy_text += text
 
-    copy_text = f'{timestamp_formatted} - {name}: '
-    if text.startswith(('```', '> ')):
-        # Prepend a line break in order to keep code block/quotes rendering
-        copy_text += '\n'
-    copy_text += text
-
-    menu_items.append(
-        (p_('Message row action', 'Copy'),
-         'win.copy-message',
-         copy_text))
+        menu_items.append(
+            (p_('Message row action', 'Copy'),
+            'win.copy-message',
+            copy_text))
+
+        show_quote = True
+        if isinstance(contact, GroupchatContact):
+            if contact.is_joined:
+                self_contact = contact.get_self()
+                assert self_contact is not None
+                show_quote = not self_contact.role.is_visitor
+            else:
+                show_quote = False
+        if show_quote:
+            menu_items.append((
+                p_('Message row action', 'Quote…'), 'win.quote', text))
 
     menu_items.append(
         (p_('Message row action', 'Select Messages…'),
          'win.activate-message-selection',
          GLib.Variant('u', log_line_id or 0)))
 
-    show_quote = True
-    if isinstance(contact, GroupchatContact):
-        if contact.is_joined:
-            self_contact = contact.get_self()
-            assert self_contact is not None
-            show_quote = not self_contact.role.is_visitor
-        else:
-            show_quote = False
-    if show_quote:
-        menu_items.append((
-            p_('Message row action', 'Quote…'), 'win.quote', text))
-
     show_correction = False
     if message_id is not None:
         show_correction = app.window.is_message_correctable(



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/fd7d760609f058d948ba990928b033de020fdddb
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