[polari/wip/carlosg/tracker: 424/445] chatView: Request log entries on map




commit 99250733be8bfc596aa008a42513bb78689959d1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 24 22:38:16 2019 +0100

    chatView: Request log entries on map
    
    If the number of rooms is high enough, querying log entries for all
    chatViews at the same time is likely going to result in a bunch of
    thread contention (since the DB interfaces are limited).
    
    Make it query on map instead, which will likely be one at a time.

 src/chatView.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 7585b53f..1bc7e21e 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -320,6 +320,16 @@ const ChatView = GObject.registerClass({
                 this._autoscroll = true;
         });
 
+        this._queriedInitialBacklog = false;
+        this.connect('map', () => {
+            if (!this._queriedInitialBacklog) {
+                this._queriedInitialBacklog = true;
+                this._fetchingBacklog = true;
+                this._logWalker.getEvents(
+                   NUM_INITIAL_LOG_EVENTS, this._onLogEventsReady.bind(this));
+            }
+        });
+
         this.vadjustment.connect('value-changed',
             this._onValueChanged.bind(this));
         this.vadjustment.connect('changed', this._updateScroll.bind(this));
@@ -361,10 +371,6 @@ const ChatView = GObject.registerClass({
 
         this._logWalker = new LogWalker(this._room);
 
-        this._fetchingBacklog = true;
-        this._logWalker.getEvents(
-           NUM_INITIAL_LOG_EVENTS, this._onLogEventsReady.bind(this));
-
         this._autoscroll = true;
         this._originalUpper = this.vadjustment.get_upper();
 


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