[epiphany/mcatanzaro/overview-placeholders: 16/17] overview.js: Avoid dropping thumbnail update requests



commit 29e4ba8d158ade2b3b3e9995423bb61e98f2f578
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Thu Jul 11 20:13:53 2019 -0500

    overview.js: Avoid dropping thumbnail update requests
    
    If about:overview is open when quitting Epiphany, then when reopening
    Epiphany the overview items will have no thumbnails. Problem is a race
    in the web process: thumbnail update requests received before
    DOMContentLoaded get dropped. So save them and apply them later.
    
    This gets us halfway to fixing the bug, but unfortunately the function
    that updates the thumbnails is also broken. I'll fix that in my next
    commit.

 .../web-process-extension/resources/js/overview.js | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/embed/web-process-extension/resources/js/overview.js 
b/embed/web-process-extension/resources/js/overview.js
index e5175c0c1..797b757fa 100644
--- a/embed/web-process-extension/resources/js/overview.js
+++ b/embed/web-process-extension/resources/js/overview.js
@@ -7,6 +7,9 @@ Ephy.Overview = class Overview
         this._model = model;
         this._items = [];
 
+        this._pendingThumbnailChanges = [];
+        this._pendingTitleChanges = [];
+
         // Event handlers are weak references in EphyWebOverviewModel, we need to keep
         // a strong reference to them while Ephy.Overview is alive.
         this._onURLsChangedFunction = this._onURLsChanged.bind(this);
@@ -47,9 +50,18 @@ Ephy.Overview = class Overview
 
             this._items.push(item);
         }
+
         let items = this._model.urls;
         if (items.length > this._items.length)
             this._onURLsChanged(items);
+
+        for (let thumbnailChange of this._pendingThumbnailChanges)
+            this._onThumbnailChanged(thumbnailChange.url, thumbnailChange.path);
+        this._pendingThumbnailChanges = [];
+
+        for (let titleChange of this._pendingTitleChanges)
+            this._onTitleChanged(titleChange.url, titleChange.title);
+        this._pendingTitleChanges = [];
     }
 
     _onKeyPress(event)
@@ -132,6 +144,11 @@ Ephy.Overview = class Overview
 
     _onThumbnailChanged(url, path)
     {
+        if (this._items.length == 0) {
+            this._pendingThumbnailChanges.push({ url: url, path: path });
+            return;
+        }
+
         for (let i = 0; i < this._items.length; i++) {
             let item = this._items[i];
             if (item.url() == url) {
@@ -143,6 +160,11 @@ Ephy.Overview = class Overview
 
     _onTitleChanged(url, title)
     {
+        if (this._items.length == 0) {
+            this._pendingTitleChanges.push({ url: url, title: title });
+            return;
+        }
+
         for (let i = 0; i < this._items.length; i++) {
             let item = this._items[i];
             if (item.url() == url) {


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