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



commit 7d43914cc845f7ad332327cb40c2c3cf1b4ab246
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]