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



commit 473e262d04705a0729f7f74ff87820b952488c71
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.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/645

 js/ui/appDisplay.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index ab819a1f2..f1e96adff 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -149,7 +149,15 @@ class BaseAppView {
 
     _loadGrid() {
         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');
     }
 


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