[gnome-music/wip/mschraal/core: 99/118] coremodel: Reuse CoreAlbums for artist view



commit 07e2169b129abf9b4deb3f97badd572edfcb9379
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 23 21:40:42 2019 +0200

    coremodel: Reuse CoreAlbums for artist view

 gnomemusic/coremodel.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 9ca0374e..ff212506 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -127,7 +127,16 @@ class CoreModel(GObject.GObject):
         albums_model_sort = Gfm.SortListModel.new(albums_model)
 
         for album in albums:
-            artist_album = CoreAlbum(album, self)
+            artist_album = None
+            for corealbum in self._album_model:
+                if album.get_id() == corealbum.props.media.get_id():
+                    artist_album = corealbum
+                    break
+
+            if artist_album is None:
+                artist_album = CoreAlbum(album, self)
+                self._album_model.append(artist_album)
+
             albums_model.append(artist_album)
 
         return albums_model


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