This is exactly what upload does. It waits until the playlist_update_in_progress callback
fires, with the `done` parameter set to true, and nothing else:
There is no Hallon-specific magic there.
Unfortunately, it’s also the only way I know of to wait for playlist sync progress. Initially
the #upload-call used #pending? on playlists, but that call was bugged and unreliable (and
as far as I know, still is). Callbacks not firing have always been an interesting problem in
Hallon, which is why I try to avoid callbacks as much as possible and just do polling.
My guess (!) would be that the callback is sometimes missed, for some weird reason. But
I’ve also had cases where the upload takes 30 seconds, even though the changes are really
reflected on the Spotify client after just a few seconds, so that’s just as likely.
You could always write your own handler for playlist_update_in_progress, and see if you
could figure out what is going wrong.
playlist.on(:playlist_update_in_progress) do |done|
# something that uses done and shows you information to help debugging
end
libspotify was not really written with this use-case in mind (add changes to playlist, wait until
they have been acknowledged by backend), so #upload is a bit of a hack to try and get it to
work at all.
— Kim