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



commit 0526665cdcec8ec3499237531af8d000126955b4
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 1370213..ee4b204 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -293,6 +293,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 = [];
@@ -301,6 +302,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() {
@@ -308,13 +310,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();
@@ -597,11 +592,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]