Yann Leboulanger pushed to branch gajim_0.16 at gajim / gajim
Commits: 8781f5aa by Philipp Hörist at 2016-12-18T23:08:54+01:00 Allow for a no limit option on restore_timeout - - - - - 29861e80 by Philipp Hörist at 2016-12-18T23:15:17+01:00 Change defaults on history restore options - - - - - 9920a2b2 by Yann Leboulanger at 2016-12-19T13:59:46+01:00 Merge branch 'restore' into 'gajim_0.16' Change history restore options - `No limit` option on 'restore_timeout' with `restore_timeout=0` - Change default values on restore values Current values of `restore_lines=4`, `restore_timeout=60` means in most cases no restore at all In recent years through Smartphone use of IM Clients, many people expect to always see at least the last X messages. With the current settings in most cases there is no history shown, and people think the Client is not capable of it. I think changing it to `restore_lines=10`, `restore_timeout=0` is sensible See merge request !7 - - - - - 3 changed files: - src/chat_control.py - src/common/config.py - src/common/logger.py Changes: ===================================== src/chat_control.py ===================================== --- a/src/chat_control.py +++ b/src/chat_control.py @@ -2991,12 +2991,6 @@ class ChatControl(ChatControlBase): if gajim.jid_is_transport(jid): return - # How many lines to restore and when to time them out - restore_how_many = gajim.config.get('restore_lines') - if restore_how_many <= 0: - return - timeout = gajim.config.get('restore_timeout') # in minutes - # number of messages that are in queue and are already logged, we want # to avoid duplication pending_how_many = len(gajim.events.get_events(self.account, jid, @@ -3006,8 +3000,8 @@ class ChatControl(ChatControlBase): self.contact.get_full_jid(), ['chat', 'pm'])) try: - rows = gajim.logger.get_last_conversation_lines(jid, restore_how_many, - pending_how_many, timeout, self.account) + rows = gajim.logger.get_last_conversation_lines( + jid, pending_how_many, self.account) except exceptions.DatabaseMalformed: import common.logger dialogs.ErrorDialog(_('Database Error'), ===================================== src/common/config.py ===================================== --- a/src/common/config.py +++ b/src/common/config.py @@ -175,8 +175,8 @@ class Config: 'notify_on_new_gmail_email_command': [ opt_str, '', _('Specify the command to run when new mail arrives, e.g.: /usr/bin/getmail -q') ], 'use_gpg_agent': [ opt_bool, False ], 'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')], - 'restore_lines': [opt_int, 4, _('How many lines to remember from previous conversation when a chat tab/window is reopened?')], - 'restore_timeout': [opt_int, 60, _('How many minutes should last lines from previous conversation last.')], + 'restore_lines': [opt_int, 10, _('How many history messages should be restored when a chat tab/window is reopened?')], + 'restore_timeout': [opt_int, 0, _('How far back in time (minutes) history is restored. 0 means no limit.')], 'muc_restore_lines': [opt_int, 20, _('How many lines to request from server when entering a groupchat. -1 means no limit')], 'muc_restore_timeout': [opt_int, 60, _('How many minutes back to request logs when entering a groupchat. -1 means no limit')], 'muc_autorejoin_timeout': [opt_int, 1, _('How many seconds to wait before trying to autorejoin to a conference you are being disconnected from. Set to 0 to disable autorejoining.')], ===================================== src/common/logger.py ===================================== --- a/src/common/logger.py +++ b/src/common/logger.py @@ -579,8 +579,7 @@ class Logger: message_col, subject_col) return self.commit_to_db(values, write_unread) - def get_last_conversation_lines(self, jid, restore_how_many_rows, - pending_how_many, timeout, account): + def get_last_conversation_lines(self, jid, pending_how_many, account): """ Accept how many rows to restore and when to time them out (in minutes) (mark them as too old) and number of messages that are in queue and are @@ -595,8 +594,15 @@ class Logger: return [] where_sql, jid_tuple = self._build_contact_where(account, jid) + # How many lines to restore and when to time them out + restore_how_many = gajim.config.get('restore_lines') + if restore_how_many <= 0: + return + timeout = gajim.config.get('restore_timeout') # in minutes + now = int(float(time.time())) - timed_out = now - (timeout * 60) # before that they are too old + if timeout != 0: + timeout = now - (timeout * 60) # before that they are too old # so if we ask last 5 lines and we have 2 pending we get # 3 - 8 (we avoid the last 2 lines but we still return 5 asked) try: @@ -606,8 +612,8 @@ class Logger: ORDER BY time DESC LIMIT %d OFFSET %d ''' % (where_sql, constants.KIND_SINGLE_MSG_RECV, constants.KIND_CHAT_MSG_RECV, constants.KIND_SINGLE_MSG_SENT, - constants.KIND_CHAT_MSG_SENT, constants.KIND_ERROR, timed_out, - restore_how_many_rows, pending_how_many), jid_tuple) + constants.KIND_CHAT_MSG_SENT, constants.KIND_ERROR, timeout, + restore_how_many, pending_how_many), jid_tuple) results = self.cur.fetchall() except sqlite.DatabaseError: View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/50c3e9476c2043bc8be217a8713f869b94365d1b...9920a2b2c4097236e6973c539f3079551d26758b
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits