M melon/models/callbacks.py => melon/models/callbacks.py +1 -0
@@ 34,6 34,7 @@ def register_callback(target: str, callback_id: str, function):
if not target in callbacks:
return
callbacks[target][callback_id] = function
+ return lambda: unregister_callback(target, callback_id)
def unregister_callback(target: str, callback_id: str):
M melon/playlist/__init__.py => melon/playlist/__init__.py +9 -1
@@ 37,10 37,16 @@ class LocalPlaylistScreen(Adw.NavigationPage):
self.playlist_id = playlist_id
# register update listener
- register_callback("playlists_changed", "playlist-view", self.do_update)
+ self.unregister = register_callback(
+ "playlists_changed", "playlist-view", self.do_update
+ )
+ self.connect("hidden", self.on_close)
# draw frame
self.do_update()
+ def on_close(self, k):
+ self.unregister()
+
def do_update(self):
# load playlist data
self.playlist = get_local_playlist(self.playlist_id)
@@ 320,6 326,8 @@ class LocalPlaylistScreen(Adw.NavigationPage):
self.dlt_diag.show()
def delete(self):
+ # make sure that this widget does not receive an update notification
+ self.unregister()
# go home and delete afterwards
# so that the reload/callback doesn't trigger
self.activate_action("win.home", None)
M melon/widgets/feeditem.py => melon/widgets/feeditem.py +1 -0
@@ 18,6 18,7 @@ from melon.utils import pass_me, many
# [url]: texture
preview_cache = {}
+
class AdaptiveFeedItem(Adw.ActionRow):
"""
FeedItem with automatic adjustment to resource type