Fixed a couple issues with per-server caching

This commit is contained in:
Sumner Evans
2019-10-29 08:46:01 -06:00
parent 8ac269899b
commit effc71c7ce
4 changed files with 32 additions and 9 deletions

View File

@@ -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()

View File

@@ -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,9 +147,8 @@ 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
meta_json = {}
if cache_meta_file.exists():
with open(cache_meta_file, 'r') as f:
try:
meta_json = json.load(f)

View File

@@ -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.

View File

@@ -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(