[gnome-shell/gbsneto/icon-grid-part1: 14/19] baseAppView: Add only non-added icons, in order



commit 36f009c37fbdec81b01d4616aa58a0b53dfd818a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Jul 1 23:01:59 2019 -0300

    baseAppView: Add only non-added icons, in order
    
    In the close future, BaseAppView will only add new icons (compared
    to the remove all + readd all approach that is now). With that, the
    items in the this._allItems array will be iterated multiple times,
    but items can only be added once, and in the order they're in the
    array.
    
    Add the items in the this._allItems array passing the index they
    should be added, and don't add icons with a parent already set.
    
    In addition to that, rename _loadGrid() to _updateGrid() in order
    to match the new semantics of it.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/645

 js/ui/appDisplay.js | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 6bdd2ee51..df51ab305 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -123,7 +123,7 @@ class BaseAppView {
     _redisplay() {
         this.removeAll();
         this._loadApps();
-        this._loadGrid();
+        this._updateGrid();
     }
 
     getAllItems() {
@@ -147,9 +147,17 @@ class BaseAppView {
         return a.name.localeCompare(b.name);
     }
 
-    _loadGrid() {
+    _updateGrid() {
         this._allItems.sort(this._compareItems);
-        this._allItems.forEach(item => this._grid.addItem(item));
+
+        this._allItems.forEach((item, index) => {
+            // Don't readd already added items
+            if (item.actor.get_parent())
+                return;
+
+            this._grid.addItem(item, index);
+        });
+
         this.emit('view-loaded');
     }
 
@@ -420,8 +428,8 @@ var AllView = class AllView extends BaseAppView {
         });
     }
 
-    _loadGrid() {
-        super._loadGrid();
+    _updateGrid() {
+        super._updateGrid();
         this._refilterApps();
     }
 


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