[gnome-shell] appDisplay: Reload folder views on installed app changes



commit 3155d03d9e97702d7dd963817bcb231bd813584e
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Feb 17 16:21:58 2020 +0100

    appDisplay: Reload folder views on installed app changes
    
    Since the FolderViews are not connected to the "installed-changed"
    signal, we need to reload their apps by calling _redisplay() when an app
    is removed or installed. We can't connect to "installed-changed" inside
    FolderView because we need to ensure _redisplay() of the FolderView is
    called before AppView tries to access the apps of the folder inside
    _refilterApps(). So reload the FolderViews inside AllViews _redisplay()
    implementation to ensure everything is up to date before accessing the
    apps of the folder.
    
    Since the "apps-changed" signal of FolderIcon now indirectly triggers a
    _redisplay() of the FolderViews, the 'changed' handler of FolderView is
    now redundant and can be removed. Because of this, we also need to move
    the emission of the "apps-changed" signal to the start of the signal
    handler to make sure the view is updated before we try to access items
    of the view.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1901
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1011

 js/ui/appDisplay.js | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 3d0bea97b3..cdd1756c2c 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -431,6 +431,10 @@ var AllView = GObject.registerClass({
 
     _redisplay() {
         super._redisplay();
+
+        this._folderIcons.forEach(icon => {
+            icon.view._redisplay();
+        });
         this._refilterApps();
     }
 
@@ -1324,20 +1328,9 @@ class FolderView extends BaseAppView {
         action.connect('pan', this._onPan.bind(this));
         this._scrollView.add_action(action);
 
-        this.connect('destroy', this._onDestroy.bind(this));
-
-        this._folderChangedId = this._folder.connect(
-            'changed', this._redisplay.bind(this));
         this._redisplay();
     }
 
-    _onDestroy() {
-        if (this._folderChangedId) {
-            this._folder.disconnect(this._folderChangedId);
-            delete this._folderChangedId;
-        }
-    }
-
     _childFocused(actor) {
         Util.ensureActorVisibleInScrollView(this._scrollView, actor);
     }
@@ -1630,10 +1623,10 @@ var FolderIcon = GObject.registerClass({
     }
 
     _sync() {
+        this.emit('apps-changed');
         this._updateName();
         this.visible = this.view.getAllItems().length > 0;
         this.icon.update();
-        this.emit('apps-changed');
     }
 
     _createIcon(iconSize) {


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