Commit a39bc1a4 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Daniel Brötzmann

Improvements

parent f85d21ee
Pipeline #6579 passed with stages
in 3 minutes and 9 seconds
......@@ -373,6 +373,7 @@ def remove_actions(self):
'information-',
'start-call-',
'send-chatstate-',
'send-marker',
]
for action in actions:
self.parent_win.window.remove_action(f'{action}{self.control_id}')
......@@ -1402,6 +1403,14 @@ def read_queue(self):
self.set_session(event.session)
if message_ids:
app.storage.archive.set_read_messages(message_ids)
# XEP-0333 Send <displayed> marker
con = app.connections[self.account]
con.get_module('ChatMarkers').send_displayed_marker(
self.contact,
self.last_msg_id,
self._type)
self.last_msg_id = None
app.events.remove_events(self.account,
jid_with_resource,
types=[str(self._type)])
......
......@@ -1114,6 +1114,7 @@ def add_message(self,
displaymarking=None,
msg_log_id=None,
message_id=None,
stanza_id=None,
correct_id=None,
additional_data=None,
marker=None,
......@@ -1158,7 +1159,10 @@ def add_message(self,
return
if message_id:
self.last_msg_id = message_id
if self._type.is_groupchat:
self.last_msg_id = stanza_id
else:
self.last_msg_id = message_id
if kind == 'incoming':
if (not self._type.is_groupchat or
......@@ -1207,6 +1211,7 @@ def add_message(self,
self,
msg_log_id,
message_id=message_id,
stanza_id=stanza_id,
show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
app.events.add_event(self.account, full_jid, event)
......@@ -1358,7 +1363,7 @@ def set_control_active(self, state):
jid = self.contact.jid
if self.conv_textview.autoscroll:
# we are at the end
type_ = ['printed_%s' % self._type]
type_ = [f'printed_{self._type}']
if self._type.is_groupchat:
type_ = ['printed_gc_msg', 'printed_marked_gc_msg']
if not app.events.remove_events(self.account,
......@@ -1366,7 +1371,7 @@ def set_control_active(self, state):
types=type_):
# There were events to remove
self.redraw_after_event_removed(jid)
# XEP-0333 Send <displayed> tag.
# XEP-0333 Send <displayed> marker
con.get_module('ChatMarkers').send_displayed_marker(
self.contact,
self.last_msg_id,
......@@ -1400,8 +1405,8 @@ def _on_edge_reached(self, _scrolledwindow, pos):
types_list = []
if self._type.is_groupchat:
types_list = ['printed_gc_msg', 'gc_msg', 'printed_marked_gc_msg']
else: # Not a GC
types_list = ['printed_%s' % self._type, str(self._type)]
else:
types_list = [f'printed_{self._type}', str(self._type)]
if not app.events.get_events(self.account, jid, types_list):
return
......
......@@ -91,14 +91,16 @@ class PmEvent(ChatEvent):
class PrintedChatEvent(Event):
type_ = 'printed_chat'
def __init__(self, message, subject, control, msg_log_id, time_=None,
message_id=None, show_in_roster=False, show_in_systray=True):
message_id=None, stanza_id=None, show_in_roster=False,
show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
show_in_systray=show_in_systray)
self.message = message
self.subject = subject
self.control = control
self.msg_log_id = msg_log_id
self.message_id = message_id
self.stanza_id = stanza_id
class PrintedGcMsgEvent(PrintedChatEvent):
type_ = 'printed_gc_msg'
......
......@@ -74,7 +74,7 @@ def _raise_event(self, name, properties):
jid = properties.jid
if not properties.is_muc_pm and not properties.type.is_groupchat:
jid = properties.jid.getBare()
jid = properties.jid.bare
app.nec.push_outgoing_event(
NetworkEvent(name,
......@@ -106,7 +106,7 @@ def _send_marker(self, contact, marker, id_, type_):
self._nbxmpp().send(message)
def send_displayed_marker(self, contact, id_, type_):
self._send_marker(contact, 'displayed', id_, type_)
self._send_marker(contact, 'displayed', id_, str(type_))
def get_instance(*args, **kwargs):
......
......@@ -255,8 +255,8 @@ class _ACCOUNT_DEFAULT:
'filetransfer_preference': 'httpupload',
'send_chatstate_default': 'composing_only',
'gc_send_chatstate_default': 'composing_only',
'send_marker_default': False,
'gc_send_marker_default': False,
'send_marker_default': True,
'gc_send_marker_default': True,
'chat_history_max_age': -1,
},
......
......@@ -38,6 +38,7 @@
from gajim.common import helpers
from gajim.common import i18n
from gajim.common.i18n import _
from gajim.common.i18n import Q_
from gajim.common.helpers import AdditionalDataDict
from gajim.common.const import StyleAttr
from gajim.common.const import Trust
......@@ -1267,7 +1268,7 @@ def set_displayed_icon_visible(self, visible):
'receipt-received-color')
self._marker_image.get_style_context().add_class(
'displayed-received-color')
self._marker_image.set_tooltip_text(_('Displayed'))
self._marker_image.set_tooltip_text(Q_('?Message state:Read'))
def set_correction_icon_visible(self, visible):
self._correction_image.set_visible(visible)
......
......@@ -295,7 +295,7 @@ button.flat.link { padding: 0; border: 0; }
/*Receipts*/
.receipt-received-color { color: rgb(75, 181, 67); }
.displayed-received-color { color: rgb(106, 0, 242); }
.displayed-received-color { color: rgb(0, 141, 242); }
/*Dataforms*/
.field-fixed { font-size: 16px; font-weight: bold; padding-top:5px;}
......
......@@ -656,6 +656,17 @@ def on_groupchat_maximize(self):
self.update_actions()
self.set_lock_image()
self.draw_banner_text()
type_ = ['printed_gc_msg', 'printed_marked_gc_msg']
if not app.events.remove_events(self.account,
self.get_full_jid(),
types=type_):
# XEP-0333 Send <displayed> marker
con = app.connections[self.account]
con.get_module('ChatMarkers').send_displayed_marker(
self.contact,
self.last_msg_id,
self._type)
self.last_msg_id = None
def _on_roster_row_activated(self, _roster, nick):
self._start_private_message(nick)
......@@ -800,6 +811,7 @@ def _on_gc_message_received(self, event):
displaymarking=event.displaymarking,
correct_id=event.correct_id,
message_id=event.properties.id,
stanza_id=event.properties.stanza_id.id,
additional_data=event.additional_data)
event.needs_highlight = self.needs_visual_notification(event.msgtxt)
......@@ -837,7 +849,7 @@ def on_private_message(self, nick, sent, msg, tim, session, additional_data,
def add_message(self, text, contact='', tim=None,
displaymarking=None, correct_id=None, message_id=None,
additional_data=None):
stanza_id=None, additional_data=None):
"""
Add message to the ConversationsTextview
......@@ -887,6 +899,7 @@ def add_message(self, text, contact='', tim=None,
displaymarking=displaymarking,
correct_id=correct_id,
message_id=message_id,
stanza_id=stanza_id,
additional_data=additional_data)
def get_nb_unread(self):
......
......@@ -242,22 +242,21 @@ def handle_event_presence(self, obj):
if ctrl and ctrl.session and len(obj.contact_list) > 1:
ctrl.remove_session(ctrl.session)
def handle_event_read_state_sync(self, event):
@staticmethod
def handle_event_read_state_sync(event):
if event.type.is_groupchat:
control = app.get_groupchat_control(
event.account, event.jid.getBare())
event.account, event.jid.bare)
if control is None:
log.warning('Groupchat control not found')
return
jid = event.jid.getBare()
jid = event.jid.bare
types = ['printed_gc_msg', 'printed_marked_gc_msg']
else:
types = ['chat', 'pm', 'printed_chat', 'printed_pm']
jid = event.jid.getBare()
if event.is_muc_pm:
jid = event.jid
jid = event.jid
control = app.interface.msg_win_mgr.get_control(jid, event.account)
......@@ -267,7 +266,12 @@ def handle_event_read_state_sync(self, event):
log.warning('No Events')
return
if events_[-1].message_id != event.marker_id:
if event.type.is_groupchat:
id_ = events_[-1].stanza_id
else:
id_ = events_[-1].message_id
if id_ != event.marker_id:
return
if not app.events.remove_events(event.account, jid, types=types):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment