[gnome-games/wip/exalm/db: 1/9] playstation: Only add games after they are complete



commit 1ee6173aa278b7b68a6263546b562f1707ba61dc
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Feb 10 19:28:11 2020 +0500

    playstation: Only add games after they are complete
    
    This ensures their MediaSet is complete by the time the callback is called.

 .../playstation/src/playstation-game-factory.vala   | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 9958edb2..7722a5aa 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -88,6 +88,8 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                        media.add_uri (uri);
                        game_for_uri[uri] = game_for_disc_set_id[disc_set_id];
 
+                       try_add_game (game_for_uri[uri]);
+
                        return;
                }
 
@@ -122,8 +124,23 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                game_for_uri[uri] = game;
                game_for_disc_set_id[disc_set_id] = game;
                games.add (game);
-               if (game_added_callback != null)
-                       game_added_callback (game);
+
+               try_add_game (game);
+       }
+
+       private void try_add_game (Game game) {
+               if (game_added_callback == null)
+                       return;
+
+               var is_complete = true;
+               game.get_media_set ().foreach_media (media => {
+                       is_complete &= (media.get_uris ().length != 0);
+               });
+
+               if (!is_complete)
+                       return;
+
+               game_added_callback (game);
        }
 
        public void foreach_game (GameCallback game_callback) {


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