diff --git a/sublime/app.py b/sublime/app.py index 1af419a..1cbc942 100644 --- a/sublime/app.py +++ b/sublime/app.py @@ -561,7 +561,7 @@ class SublimeMusicApp(Gtk.Application): self.loading_state = False # Update the window according to the new server configuration. - self.update_window(force=True) + self.update_window() def on_stack_change(self, stack, child): self.state.current_tab = stack.get_visible_child_name() diff --git a/sublime/cache_manager.py b/sublime/cache_manager.py index cebfef8..e96c641 100644 --- a/sublime/cache_manager.py +++ b/sublime/cache_manager.py @@ -86,6 +86,8 @@ class CacheManager(metaclass=Singleton): @staticmethod def calculate_server_hash(server: ServerConfiguration): + if server is None: + return None server_info = (server.name + server.server_address + server.username) return hashlib.md5(server_info.encode('utf-8')).hexdigest()[:8] @@ -145,14 +147,13 @@ class CacheManager(metaclass=Singleton): def load_cache_info(self): cache_meta_file = self.calculate_abs_path('.cache_meta') - if not cache_meta_file.exists(): - return - - with open(cache_meta_file, 'r') as f: - try: - meta_json = json.load(f) - except json.decoder.JSONDecodeError: - return + meta_json = {} + if cache_meta_file.exists(): + with open(cache_meta_file, 'r') as f: + try: + meta_json = json.load(f) + except json.decoder.JSONDecodeError: + return cache_configs = [ # Playlists diff --git a/sublime/ui/albums.py b/sublime/ui/albums.py index 613a7fd..e5cba15 100644 --- a/sublime/ui/albums.py +++ b/sublime/ui/albums.py @@ -291,6 +291,7 @@ class AlbumsGrid(Gtk.Overlay): parameters_changed = False current_min_size_request = 30 overshoot_update_in_progress = False + server_hash = None def update_params( self, @@ -383,6 +384,11 @@ class AlbumsGrid(Gtk.Overlay): force: bool = False, selected_id: str = None, ): + new_hash = CacheManager.calculate_server_hash(state.config.server) + if self.server_hash != new_hash: + self.parameters_changed = True + self.server_hash = new_hash + self.update_grid(force=force, selected_id=selected_id) # Update the detail panel. diff --git a/sublime/ui/artists.py b/sublime/ui/artists.py index 600958c..63e8e82 100644 --- a/sublime/ui/artists.py +++ b/sublime/ui/artists.py @@ -251,7 +251,20 @@ class ArtistDetailPanel(Gtk.Box): def update(self, state: ApplicationState): if state.selected_artist_id is None: self.artist_action_buttons.hide() + self.artist_id = None + self.artist_indicator.set_text('') + self.artist_name.set_markup('') + self.artist_stats.set_markup('') + + self.artist_bio.set_markup('') + self.similar_artists_box.hide() + + self.artist_artwork.set_from_file(None) + + self.albums = [] + self.albums_list.update(None) else: + self.artist_action_buttons.show() self.update_artist_view(state.selected_artist_id, state=state) # TODO need to handle when this is force updated. Need to delete a bunch of @@ -402,6 +415,9 @@ class AlbumsListWithSongs(Gtk.Overlay): for c in self.box.get_children(): self.box.remove(c) + if artist is None: + return + for album in artist.get('album', artist.get('child', [])): album_with_songs = AlbumWithSongs(album, show_artist_name=False) album_with_songs.connect(