danielfm / smudge

Control the Spotify app from within Emacs.
https://asciinema.org/a/218654
GNU General Public License v3.0
309 stars 47 forks source link

Call status after activity & reduce number of calls #56

Closed jkdufair closed 3 years ago

jkdufair commented 4 years ago

I attempted to handle various nested sets of callbacks to get the status after the API calls were complete but it truly was callback hell and required a lot of ugly, repetitive code. I think the right approach would be to use something like aio or whatever is considered the best async/await/promise library currently. As it stands, I just hacked in a 1s timer to get status after any call is made.

Also, using define-globalized-minor-mode was causing spotify-remote-mode to be called repeatedly on every switch from a buffer another buffer (or to the minibuffer). This was causing many unnecessary API calls because I had assumed the minor mode function would be called once. By specifying :global in the minor mode definition, the minor mode function is now called once for each toggle. This does prevent us from offering a buffer-specific minor mode, but that doesn't seem very useful anyway?

jkdufair commented 3 years ago

@danielfm I think this should be ready to go too. Seems to be responding better to track changes, picking up the device right on startup.