On the song detail page, the way we keep track of frontend state of syncs is a huuuge hack. It's pretty lucky that it works as well as it does. It completely explodes if a user has multiple syncprojects tabs open, since the messages will be consumed by whichever tab reads them first, leaving both in a potentially bad state. There's also no way to recover from said states without refreshing the page or possibly flushing localstorage. We are also polluting localstorage with a bunch of garbage that is building up over time.
The new implementation should store very little state on the frontend. After page load, we should pull song info from the API. If the song is checked out according to the API AND we have state stored saying we checked it out from this browser, then the buttons on the page should reflect the ability to check in. Otherwise, the option to check the song out should be available and we should clear local state. Though, we do need to handle page refreshes during a sync (while this is still not a single-page app...), so maybe the sync ID is still needed. We certainly need to find a way to identify a particular browser tab and whether it is the one handling the sync.
The message-parsing logic could use an overhaul too, but it is mostly functional.
On the song detail page, the way we keep track of frontend state of syncs is a huuuge hack. It's pretty lucky that it works as well as it does. It completely explodes if a user has multiple syncprojects tabs open, since the messages will be consumed by whichever tab reads them first, leaving both in a potentially bad state. There's also no way to recover from said states without refreshing the page or possibly flushing localstorage. We are also polluting localstorage with a bunch of garbage that is building up over time.
The new implementation should store very little state on the frontend. After page load, we should pull song info from the API. If the song is checked out according to the API AND we have state stored saying we checked it out from this browser, then the buttons on the page should reflect the ability to check in. Otherwise, the option to check the song out should be available and we should clear local state. Though, we do need to handle page refreshes during a sync (while this is still not a single-page app...), so maybe the sync ID is still needed. We certainly need to find a way to identify a particular browser tab and whether it is the one handling the sync.
The message-parsing logic could use an overhaul too, but it is mostly functional.