[polari/wip/fmuellner/tracker: 8/9] chatView: Postpone fetching backlog until mapped



commit 33df263413cd47ce004790078a84bc14ec6266c8
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri May 20 23:54:23 2016 +0200

    chatView: Postpone fetching backlog until mapped
    
    Tracker (or more precisely: threading restrictions imposed by the
    underlying sqlite database) becomes a bottleneck when running too
    many queries simultaneously. Depending on the number of channels,
    this can be quite noticeable when fetching backlogs for all channels
    on startup. Avoid this by only fetching the initial backlog when
    mapping the chat log for the first time.

 src/chatView.js |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 41ab3f9..b973702 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -292,6 +292,7 @@ const ChatView = new Lang.Class({
         this._state = { lastNick: null, lastTimestamp: 0, lastStatusGroup: 0 };
         this._active = false;
         this._toplevelFocus = false;
+        this._fetchingBacklog = false;
         this._joinTime = 0;
         this._maxNickChars = MAX_NICK_CHARS;
         this._hoveredButtonTags = [];
@@ -300,6 +301,7 @@ const ChatView = new Lang.Class({
         this._pendingLogs = [];
         this._initialPending = [];
         this._statusCount = { left: 0, joined: 0, total: 0 };
+        this._logWalker = null;
 
         this._room.account.connect('notify::nickname', Lang.bind(this,
             function() {
@@ -307,13 +309,6 @@ const ChatView = new Lang.Class({
             }));
         this._updateMaxNickChars(this._room.account.nickname.length);
 
-        let logManager = LogManager.getDefault();
-        this._logWalker = logManager.walkEvents(room);
-
-        this._fetchingBacklog = true;
-        this._logWalker.getEvents(NUM_INITIAL_LOG_EVENTS,
-                                  Lang.bind(this, this._onLogEventsReady));
-
         this._autoscroll = true;
 
         this._app = Gio.Application.get_default();
@@ -596,11 +591,24 @@ const ChatView = new Lang.Class({
         this._view.left_margin = MARGIN + totalWidth;
     },
 
+    _ensureLogWalker: function() {
+        if (this._logWalker)
+            return;
+
+        let logManager = LogManager.getDefault();
+        this._logWalker = logManager.walkEvents(this._room);
+
+        this._fetchingBacklog = true;
+        this._logWalker.getEvents(NUM_INITIAL_LOG_EVENTS,
+                                  Lang.bind(this, this._onLogEventsReady));
+    },
+
     _updateActive: function() {
         let active = this.get_mapped();
         if (this._active == active)
             return;
         this._active = active;
+        this._ensureLogWalker();
         this._checkMessages();
     },
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]