[gnome-shell] mpris: Use a scope specific message instead of a global one



commit d5e8f8cdf7aa3cf6525d58ecfbba05832df3d8a6
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sun Nov 17 16:24:52 2019 +0100

    mpris: Use a scope specific message instead of a global one
    
    Since the mpris implementation of the notification tray supports showing
    multiple notification (one for each player), it doesn't make sense to
    have only one global property to store the message, since that only
    allows referencing one message at a time.
    
    Instead, handle the MediaMessages completely inside the scope of
    `_addPlayer()`, this should allow showing more than one message again,
    which broke with commit 4dc44304dff2974d3b026b5aa58e0d5c25d38216 [1].
    
    [1] https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/791
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/833

 js/ui/mpris.js | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/mpris.js b/js/ui/mpris.js
index 5a936b5af9..a16e56b5da 100644
--- a/js/ui/mpris.js
+++ b/js/ui/mpris.js
@@ -256,18 +256,20 @@ class MediaSection extends MessageList.MessageListSection {
             return;
 
         let player = new MprisPlayer(busName);
+        let message = null;
         player.connect('closed',
             () => {
                 this._players.delete(busName);
             });
         player.connect('show', () => {
-            this._message = new MediaMessage(player);
-            this.addMessage(this._message, true);
+            message = new MediaMessage(player);
+            this.addMessage(message, true);
         });
         player.connect('hide', () => {
-            this.removeMessage(this._message, true);
-            this._message = null;
+            this.removeMessage(message, true);
+            message = null;
         });
+
         this._players.set(busName, player);
     }
 
@@ -288,10 +290,7 @@ class MediaSection extends MessageList.MessageListSection {
         if (!name.startsWith(MPRIS_PLAYER_PREFIX))
             return;
 
-        if (newOwner && !oldOwner) {
-            if (this._message)
-                this.removeMessage(this._message);
+        if (newOwner && !oldOwner)
             this._addPlayer(name);
-        }
     }
 });


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