File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ const useLibrespot = (websocketUrl, apiBaseUrl) => {
6262 // (Re)load on initial render or whenever the API endpoint changes.
6363 useEffect ( ( ) => {
6464 const fetchStatus = async ( ) => {
65+ console . log ( "Refreshing state" ) ;
6566 const data = await getStatus ( apiBaseUrl ) ;
6667 const isStopped = data . stopped || ! data . play_origin . length || data . track == null ;
6768 setStatus ( data ) ; //< TODO: remove long term.
@@ -73,8 +74,11 @@ const useLibrespot = (websocketUrl, apiBaseUrl) => {
7374 setShuffleContext ( data . shuffle_context ) ;
7475 setRemotePosition ( data . track ?. position || 0 ) ;
7576 } ;
76- fetchStatus ( ) ;
77- } , [ apiBaseUrl ] ) ;
77+ // Refresh state on each (re)connect
78+ if ( isConnected ) {
79+ fetchStatus ( ) ;
80+ }
81+ } , [ apiBaseUrl , isConnected ] ) ;
7882
7983 // Call pause or resume depending on the current state of the player
8084 const handlePlayPause = ( ) => {
You can’t perform that action at this time.
0 commit comments