Philipp Hörist pushed to branch master at gajim / gajim
Commits:
e0bc8c92 by Philipp Hörist at 2020-02-01T10:30:20+01:00
Logger: Preload DiscoInfo
There are times for example when we open the StartChat Dialog, where
we need potentially hundreads of DiscoInfo entrys instantly.
If we execute a database query for each one of them this becomes a
bottleneck
- - - - -
1 changed file:
- gajim/common/logger.py
Changes:
=====================================
gajim/common/logger.py
=====================================
@@ -234,6 +234,7 @@ class Logger:
self._migrate_databases()
self._connect_databases()
self._get_jid_ids_from_db()
+ self._fill_disco_info_cache()
def _create_databases(self):
if os.path.isdir(self._log_db_path):
@@ -1670,6 +1671,17 @@ class Logger:
log.info('Set message archive info: %s %s', jid, kwargs)
self._timeout_commit()
+ @timeit
+ def _fill_disco_info_cache(self):
+ sql = '''SELECT disco_info as "disco_info [disco_info]",
+ jid, last_seen FROM
+ last_seen_disco_info'''
+ rows = self._con.execute(sql).fetchall()
+ for row in rows:
+ disco_info = row.disco_info._replace(timestamp=row.last_seen)
+ self._disco_info_cache[row.jid] = disco_info
+ log.info('%s DiscoInfo entrys loaded', len(rows))
+
@timeit
def get_last_disco_info(self, jid, max_age=0):
"""
@@ -1681,28 +1693,11 @@ class Logger:
"""
- max_timestamp = time.time() - max_age if max_age else 0
-
- # Try the cache
disco_info = self._disco_info_cache.get(jid)
if disco_info is not None:
+ max_timestamp = time.time() - max_age if max_age else 0
if max_timestamp > disco_info.timestamp:
return None
- return disco_info
-
- # Try the database
- sql = '''SELECT disco_info as "disco_info [disco_info]", last_seen FROM
- last_seen_disco_info
- WHERE jid = ?'''
- row = self._con.execute(sql, (str(jid),)).fetchone()
- if row is None:
- return None
-
- if max_timestamp > row.last_seen:
- return None
-
- disco_info = row.disco_info._replace(timestamp=row.last_seen)
- self._disco_info_cache[jid] = disco_info
return disco_info
@timeit
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/e0bc8c9284f441039aa7aa2b6a0849b88f…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/e0bc8c9284f441039aa7aa2b6a0849b88f…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
9a8ca991 by Daniel Brötzmann at 2020-01-31T15:04:23+01:00
Roster: Show group chat description instead of topic
- - - - -
1 changed file:
- gajim/roster_window.py
Changes:
=====================================
gajim/roster_window.py
=====================================
@@ -1205,17 +1205,23 @@ class RosterWindow:
# add status msg, if not empty, under contact name in
# the treeview
- if contact.status and app.config.get('show_status_msgs_in_roster'):
- status = contact.status.strip()
- if status != '':
- status = helpers.reduce_chars_newlines(status,
- max_lines=1)
- # escape markup entities and make them small
-
- # italic
- name += ('\n<span size="small" style="italic" '
- 'alpha="70%">{}</span>'.format(
- GLib.markup_escape_text(status)))
+ if app.config.get('show_status_msgs_in_roster'):
+ status_span = '\n<span size="small" style="italic" ' \
+ 'alpha="70%">{}</span>'
+ if contact.is_groupchat:
+ disco_info = app.logger.get_last_disco_info(contact.jid)
+ if disco_info is not None:
+ description = disco_info.muc_description
+ if description:
+ name += status_span.format(
+ GLib.markup_escape_text(description))
+ elif contact.status:
+ status = contact.status.strip()
+ if status != '':
+ status = helpers.reduce_chars_newlines(
+ status, max_lines=1)
+ name += status_span.format(
+ GLib.markup_escape_text(status))
icon_name = helpers.get_icon_name_to_show(contact, account)
# look if another resource has awaiting events
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/9a8ca9918cc9e9952ea08f97295e56437d…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/9a8ca9918cc9e9952ea08f97295e56437d…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
4ef83834 by Daniel Brötzmann at 2020-01-29T22:54:36+01:00
Themes: Set default style value when adding a setting
- - - - -
1 changed file:
- gajim/gtk/themes.py
Changes:
=====================================
gajim/gtk/themes.py
=====================================
@@ -256,10 +256,16 @@ class Themes(Gtk.ApplicationWindow):
if first is None:
self._on_add_new_theme()
+ # Don't add an option twice
for option in self._ui.option_listbox.get_children():
if option == row:
return
- row = Option(row.option, None)
+
+ # Get default value if it exists
+ value = app.css_config.get_value(
+ row.option.selector, row.option.attr)
+
+ row = Option(row.option, value)
self._ui.option_listbox.add(row)
self._ui.option_popover.popdown()
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/4ef838344744ce4d60e30ea34e97d00198…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/4ef838344744ce4d60e30ea34e97d00198…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
7ba0cfcb by Philipp Hörist at 2020-01-29T22:46:38+01:00
Remove unused imports
- - - - -
1 changed file:
- gajim/common/modules/message.py
Changes:
=====================================
gajim/common/modules/message.py
=====================================
@@ -23,7 +23,6 @@ from nbxmpp.util import generate_id
from gajim.common import app
from gajim.common.nec import NetworkEvent
from gajim.common.helpers import AdditionalDataDict
-from gajim.common.helpers import validate_jid
from gajim.common.const import KindConstant
from gajim.common.modules.base import BaseModule
from gajim.common.modules.util import get_eme_message
@@ -31,8 +30,6 @@ from gajim.common.modules.security_labels import parse_securitylabel
from gajim.common.modules.misc import parse_correction
from gajim.common.modules.misc import parse_oob
from gajim.common.modules.misc import parse_xhtml
-from gajim.common.connection_handlers_events import InformationEvent
-from gajim.common.connection_handlers_events import MessageSentEvent
class Message(BaseModule):
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/7ba0cfcbdc6f3d8dd90f8e00fbc50ee4c5…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/7ba0cfcbdc6f3d8dd90f8e00fbc50ee4c5…
You're receiving this email because of your account on dev.gajim.org.