@@ -6,8 +6,10 @@ import Settings from "./components/Settings/Settings";
66import { sendNocturneWsRequest } from "../../hooks/useNocturned" ;
77import "./styles/MockingbirdShell.scss" ;
88
9- const LazySetup = React . lazy ( ( ) => import ( './components/Setup/Setup' ) ) ;
10- const LazyOnboarding = React . lazy ( ( ) => import ( './components/Onboarding/Onboarding' ) ) ;
9+ const LazySetup = React . lazy ( ( ) => import ( "./components/Setup/Setup" ) ) ;
10+ const LazyOnboarding = React . lazy (
11+ ( ) => import ( "./components/Onboarding/Onboarding" ) ,
12+ ) ;
1113
1214const mockingbirdFontStyles = `
1315@font-face {
@@ -37,13 +39,15 @@ function usePlaybackPolling(parentPlayback) {
3739
3840 const poll = useCallback ( async ( ) => {
3941 try {
40- const data = await sendNocturneWsRequest ( "spotify.player.state" , { } , { timeoutMs : 5000 } ) ;
42+ const data = await sendNocturneWsRequest (
43+ "spotify.player.state" ,
44+ { } ,
45+ { timeoutMs : 5000 } ,
46+ ) ;
4147 if ( data && data . item && ! stoppedRef . current ) {
4248 setLocalPlayback ( data ) ;
4349 }
44- } catch ( e ) {
45-
46- }
50+ } catch ( e ) { }
4751 if ( ! stoppedRef . current ) {
4852 pollingRef . current = setTimeout ( poll , 3000 ) ;
4953 }
@@ -118,57 +122,151 @@ function useSpotifyData() {
118122 id : "4m2880jivSbbyEGAKfITCa" ,
119123 uri : "spotify:album:4m2880jivSbbyEGAKfITCa" ,
120124 name : "Random Access Memories" ,
121- artists : [ { id : "4tZwfgrHOc3mvqYlEYSvVi" , name : "Daft Punk" , type : "artist" , uri : "spotify:artist:4tZwfgrHOc3mvqYlEYSvVi" } ] ,
122- images : [ { url : "https://i.scdn.co/image/ab67616d00001e029b9b36b0e22870b9f542d937" } ] ,
125+ artists : [
126+ {
127+ id : "4tZwfgrHOc3mvqYlEYSvVi" ,
128+ name : "Daft Punk" ,
129+ type : "artist" ,
130+ uri : "spotify:artist:4tZwfgrHOc3mvqYlEYSvVi" ,
131+ } ,
132+ ] ,
133+ images : [
134+ {
135+ url : "https://i.scdn.co/image/ab67616d00001e029b9b36b0e22870b9f542d937" ,
136+ } ,
137+ ] ,
123138 } ,
124139 {
125140 id : "7xl50xr9NDkd3i2kBbzsNZ" ,
126141 uri : "spotify:album:7xl50xr9NDkd3i2kBbzsNZ" ,
127142 name : "Stadium Arcadium" ,
128- artists : [ { id : "0L8ExT028jH3ddEcZwqJJ5" , name : "Red Hot Chili Peppers" , type : "artist" , uri : "spotify:artist:0L8ExT028jH3ddEcZwqJJ5" } ] ,
129- images : [ { url : "https://i.scdn.co/image/ab67616d00001e0209fd83d32aee93dceba78517" } ] ,
143+ artists : [
144+ {
145+ id : "0L8ExT028jH3ddEcZwqJJ5" ,
146+ name : "Red Hot Chili Peppers" ,
147+ type : "artist" ,
148+ uri : "spotify:artist:0L8ExT028jH3ddEcZwqJJ5" ,
149+ } ,
150+ ] ,
151+ images : [
152+ {
153+ url : "https://i.scdn.co/image/ab67616d00001e0209fd83d32aee93dceba78517" ,
154+ } ,
155+ ] ,
130156 } ,
131157 {
132158 id : "78bpIziExqiI9qztvNFlQu" ,
133159 uri : "spotify:album:78bpIziExqiI9qztvNFlQu" ,
134160 name : "AM" ,
135- artists : [ { id : "7Ln80lUS6He07XvHI8qqHH" , name : "Arctic Monkeys" , type : "artist" , uri : "spotify:artist:7Ln80lUS6He07XvHI8qqHH" } ] ,
136- images : [ { url : "https://i.scdn.co/image/ab67616d00001e024ae1c4c5c45aabe565499163" } ] ,
161+ artists : [
162+ {
163+ id : "7Ln80lUS6He07XvHI8qqHH" ,
164+ name : "Arctic Monkeys" ,
165+ type : "artist" ,
166+ uri : "spotify:artist:7Ln80lUS6He07XvHI8qqHH" ,
167+ } ,
168+ ] ,
169+ images : [
170+ {
171+ url : "https://i.scdn.co/image/ab67616d00001e024ae1c4c5c45aabe565499163" ,
172+ } ,
173+ ] ,
137174 } ,
138175 {
139176 id : "0bQglEvsHphrS19FGODEGo" ,
140177 uri : "spotify:album:0bQglEvsHphrS19FGODEGo" ,
141178 name : "Siamese Dream (Deluxe Edition)" ,
142- artists : [ { id : "40Yq4vzPs9VNUrIBG5Jr2i" , name : "The Smashing Pumpkins" , type : "artist" , uri : "spotify:artist:40Yq4vzPs9VNUrIBG5Jr2i" } ] ,
143- images : [ { url : "https://i.scdn.co/image/ab67616d00001e025274788f34fc7656d2856dfd" } ] ,
179+ artists : [
180+ {
181+ id : "40Yq4vzPs9VNUrIBG5Jr2i" ,
182+ name : "The Smashing Pumpkins" ,
183+ type : "artist" ,
184+ uri : "spotify:artist:40Yq4vzPs9VNUrIBG5Jr2i" ,
185+ } ,
186+ ] ,
187+ images : [
188+ {
189+ url : "https://i.scdn.co/image/ab67616d00001e025274788f34fc7656d2856dfd" ,
190+ } ,
191+ ] ,
144192 } ,
145193 {
146194 id : "0bCAjiUamIFqKJsekOYuRw" ,
147195 uri : "spotify:album:0bCAjiUamIFqKJsekOYuRw" ,
148196 name : "Wish You Were Here" ,
149- artists : [ { id : "0k17h0D3J5VfsdmQ1iZtE9" , name : "Pink Floyd" , type : "artist" , uri : "spotify:artist:0k17h0D3J5VfsdmQ1iZtE9" } ] ,
150- images : [ { url : "https://i.scdn.co/image/ab67616d00001e02828e52cfb7bf22869349799e" } ] ,
197+ artists : [
198+ {
199+ id : "0k17h0D3J5VfsdmQ1iZtE9" ,
200+ name : "Pink Floyd" ,
201+ type : "artist" ,
202+ uri : "spotify:artist:0k17h0D3J5VfsdmQ1iZtE9" ,
203+ } ,
204+ ] ,
205+ images : [
206+ {
207+ url : "https://i.scdn.co/image/ab67616d00001e02828e52cfb7bf22869349799e" ,
208+ } ,
209+ ] ,
151210 } ,
152211 {
153212 id : "2ODvWsOgouMbaA5xf0RkJe" ,
154213 uri : "spotify:album:2ODvWsOgouMbaA5xf0RkJe" ,
155214 name : "Starboy" ,
156- artists : [ { id : "1Xyo4u8uXC1ZmMpatF05PJ" , name : "The Weeknd" , type : "artist" , uri : "spotify:artist:1Xyo4u8uXC1ZmMpatF05PJ" } , { id : "4tZwfgrHOc3mvqYlEYSvVi" , name : "Daft Punk" , type : "artist" , uri : "spotify:artist:4tZwfgrHOc3mvqYlEYSvVi" } ] ,
157- images : [ { url : "https://i.scdn.co/image/ab67616d00001e024718e2b124f79258be7bc452" } ] ,
215+ artists : [
216+ {
217+ id : "1Xyo4u8uXC1ZmMpatF05PJ" ,
218+ name : "The Weeknd" ,
219+ type : "artist" ,
220+ uri : "spotify:artist:1Xyo4u8uXC1ZmMpatF05PJ" ,
221+ } ,
222+ {
223+ id : "4tZwfgrHOc3mvqYlEYSvVi" ,
224+ name : "Daft Punk" ,
225+ type : "artist" ,
226+ uri : "spotify:artist:4tZwfgrHOc3mvqYlEYSvVi" ,
227+ } ,
228+ ] ,
229+ images : [
230+ {
231+ url : "https://i.scdn.co/image/ab67616d00001e024718e2b124f79258be7bc452" ,
232+ } ,
233+ ] ,
158234 } ,
159235 {
160236 id : "2IdHrETl3jsOYQRsF0nV16" ,
161237 uri : "spotify:album:2IdHrETl3jsOYQRsF0nV16" ,
162238 name : "Midnight Sun" ,
163- artists : [ { id : "1Xylc3o4UrD53lo9CvFvVg" , name : "Zara Larsson" , type : "artist" , uri : "spotify:artist:1Xylc3o4UrD53lo9CvFvVg" } ] ,
164- images : [ { url : "https://i.scdn.co/image/ab67616d00001e027657f9028ea8bb2c18dca99f" } ] ,
239+ artists : [
240+ {
241+ id : "1Xylc3o4UrD53lo9CvFvVg" ,
242+ name : "Zara Larsson" ,
243+ type : "artist" ,
244+ uri : "spotify:artist:1Xylc3o4UrD53lo9CvFvVg" ,
245+ } ,
246+ ] ,
247+ images : [
248+ {
249+ url : "https://i.scdn.co/image/ab67616d00001e027657f9028ea8bb2c18dca99f" ,
250+ } ,
251+ ] ,
165252 } ,
166253 {
167254 id : "55RhFRyQFihIyGf61MgcfV" ,
168255 uri : "spotify:album:55RhFRyQFihIyGf61MgcfV" ,
169256 name : "Mellon Collie And The Infinite Sadness (Deluxe Edition)" ,
170- artists : [ { id : "40Yq4vzPs9VNUrIBG5Jr2i" , name : "The Smashing Pumpkins" , type : "artist" , uri : "spotify:artist:40Yq4vzPs9VNUrIBG5Jr2i" } ] ,
171- images : [ { url : "https://i.scdn.co/image/ab67616d00001e02431ac6e6f393acf475730ec6" } ] ,
257+ artists : [
258+ {
259+ id : "40Yq4vzPs9VNUrIBG5Jr2i" ,
260+ name : "The Smashing Pumpkins" ,
261+ type : "artist" ,
262+ uri : "spotify:artist:40Yq4vzPs9VNUrIBG5Jr2i" ,
263+ } ,
264+ ] ,
265+ images : [
266+ {
267+ url : "https://i.scdn.co/image/ab67616d00001e02431ac6e6f393acf475730ec6" ,
268+ } ,
269+ ] ,
172270 } ,
173271 ] ;
174272
@@ -184,12 +282,13 @@ function useSpotifyData() {
184282 attempts ++ ;
185283
186284 try {
187- const [ recentRaw , playlistsRaw , artistsRaw , showsRaw ] = await Promise . all ( [
188- fetchEndpoint ( "spotify.me.recentlyPlayed" , { limit : 10 } ) ,
189- fetchEndpoint ( "spotify.me.playlists" , { limit : 50 } ) ,
190- fetchEndpoint ( "spotify.me.topArtists" , { limit : 20 } ) ,
191- fetchEndpoint ( "spotify.me.shows" , { limit : 20 } ) ,
192- ] ) ;
285+ const [ recentRaw , playlistsRaw , artistsRaw , showsRaw ] =
286+ await Promise . all ( [
287+ fetchEndpoint ( "spotify.me.recentlyPlayed" , { limit : 10 } ) ,
288+ fetchEndpoint ( "spotify.me.playlists" , { limit : 50 } ) ,
289+ fetchEndpoint ( "spotify.me.topArtists" , { limit : 20 } ) ,
290+ fetchEndpoint ( "spotify.me.shows" , { limit : 20 } ) ,
291+ ] ) ;
193292
194293 if ( cancelled ) return ;
195294
@@ -198,9 +297,12 @@ function useSpotifyData() {
198297 let topArtists = artistsRaw ?. items || artistsRaw || [ ] ;
199298 let userShows = showsRaw ?. items || showsRaw || [ ] ;
200299
201- const allLoaded = recentAlbums . length > 0 &&
202- Array . isArray ( userPlaylists ) && userPlaylists . length > 0 &&
203- Array . isArray ( topArtists ) && topArtists . length > 0 ;
300+ const allLoaded =
301+ recentAlbums . length > 0 &&
302+ Array . isArray ( userPlaylists ) &&
303+ userPlaylists . length > 0 &&
304+ Array . isArray ( topArtists ) &&
305+ topArtists . length > 0 ;
204306
205307 if ( ! allLoaded && attempts < MAX_ATTEMPTS ) {
206308 if ( ! cancelled ) {
@@ -218,31 +320,36 @@ function useSpotifyData() {
218320
219321 if ( recentAlbums . length < 3 && ! cancelled ) {
220322 try {
221- const likedRaw = await fetchEndpoint ( "spotify.me.tracks" , { limit : 20 , mockingbird : true } ) ;
323+ const likedRaw = await fetchEndpoint ( "spotify.me.tracks" , {
324+ limit : 20 ,
325+ mockingbird : true ,
326+ } ) ;
222327 if ( ! cancelled && likedRaw ) {
223- const likedItems = likedRaw ?. items || likedRaw ?. tracks || likedRaw || [ ] ;
224- const seenIds = new Set ( recentAlbums . map ( a => a . id ) ) ;
328+ const likedItems =
329+ likedRaw ?. items || likedRaw ?. tracks || likedRaw || [ ] ;
330+ const seenIds = new Set ( recentAlbums . map ( ( a ) => a . id ) ) ;
225331 for ( const item of Array . isArray ( likedItems ) ? likedItems : [ ] ) {
226332 const track = item . track || item ;
227333 const album = track ?. album ;
228334 if ( album && album . id && ! seenIds . has ( album . id ) ) {
229335 seenIds . add ( album . id ) ;
230- if ( ! album . artists && track . artists ) album . artists = track . artists ;
336+ if ( ! album . artists && track . artists )
337+ album . artists = track . artists ;
231338 recentAlbums . push ( album ) ;
232339 if ( recentAlbums . length >= 8 ) break ;
233340 }
234341 }
235342 }
236- } catch ( e ) {
237-
238- }
343+ } catch ( e ) { }
239344 }
240345
241346 if ( cancelled ) return ;
242347
243348 const rootStore = window . carThingRootStore ;
244349 if ( rootStore ?. shelfStore ) {
245- runInAction ( ( ) => rootStore . shelfStore . seedRecentAlbums ( recentAlbums ) ) ;
350+ runInAction ( ( ) =>
351+ rootStore . shelfStore . seedRecentAlbums ( recentAlbums ) ,
352+ ) ;
246353 }
247354
248355 setData ( {
@@ -255,7 +362,6 @@ function useSpotifyData() {
255362 initialDataLoaded : true ,
256363 } ) ;
257364 } catch ( e ) {
258-
259365 if ( ! cancelled ) {
260366 retryTimer = setTimeout ( fetchData , 1500 ) ;
261367 }
@@ -342,10 +448,12 @@ export default function MockingbirdShell({
342448} ) {
343449 const currentPlayback = usePlaybackPolling ( parentPlayback ) ;
344450 const localSpotifyData = useSpotifyData ( ) ;
345- const spotifyData = parentSpotifyData ?. initialDataLoaded ? parentSpotifyData : localSpotifyData ;
451+ const spotifyData = parentSpotifyData ?. initialDataLoaded
452+ ? parentSpotifyData
453+ : localSpotifyData ;
346454 const dataReady = spotifyData . initialDataLoaded ;
347455
348- if ( systemScreen && systemScreen !== ' tutorial' ) {
456+ if ( systemScreen && systemScreen !== " tutorial" ) {
349457 return (
350458 < div className = "mockingbird-root" >
351459 < style > { mockingbirdFontStyles } </ style >
@@ -365,7 +473,7 @@ export default function MockingbirdShell({
365473 ) ;
366474 }
367475
368- if ( systemScreen === ' tutorial' ) {
476+ if ( systemScreen === " tutorial" ) {
369477 return (
370478 < div className = "mockingbird-root" >
371479 < style > { mockingbirdFontStyles } </ style >
@@ -380,7 +488,10 @@ export default function MockingbirdShell({
380488 onSeek = { playerControls ?. seekToPosition }
381489 >
382490 < React . Suspense fallback = { < SplashOverlay /> } >
383- < LazyOnboarding onComplete = { onTutorialComplete } dataReady = { dataReady } />
491+ < LazyOnboarding
492+ onComplete = { onTutorialComplete }
493+ dataReady = { dataReady }
494+ />
384495 </ React . Suspense >
385496 </ CarThingStoreProvider >
386497 ) }
0 commit comments