[polari/wip/carlosg/tracker: 3/16] chatView: Request log entries on map



commit 9f1ac3c90dc8383cdef831f9269c478706684bd4
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 f604d0f..00b9bff 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -313,6 +313,16 @@ var 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));
@@ -352,10 +362,6 @@ var 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._app = Gio.Application.get_default();


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