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



commit 6137bc2f05cdcb2e48a2daf54ef0475841b22dc8
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 |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 52a8d9d..25350cb 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -281,6 +281,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 = [];
@@ -288,6 +289,7 @@ const ChatView = new Lang.Class({
         this._pending = {};
         this._pendingLogs = [];
         this._statusCount = { left: 0, joined: 0, total: 0 };
+        this._logWalker = null;
 
         this._room.account.connect('notify::nickname', Lang.bind(this,
             function() {
@@ -295,13 +297,6 @@ const ChatView = new Lang.Class({
             }));
         this._updateMaxNickChars(this._room.account.nickname.length);
 
-        let logManager = LogManager.getDefault();
-        this._logWalker = logManager.walkEvents(room.account, room.channel_name);
-
-        this._fetchingBacklog = true;
-        this._logWalker.getEvents(NUM_INITIAL_LOG_EVENTS,
-                                  Lang.bind(this, this._onLogEventsReady));
-
         let adj = this.vadjustment;
         this._scrollBottom = adj.upper - adj.page_size;
 
@@ -542,11 +537,25 @@ 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.account,
+                                                this._room.channel_name);
+
+        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]