From 7cc8bc71725578f176a7e6e1e7606e7443c8a77e Mon Sep 17 00:00:00 2001 From: Gil Barbara Date: Tue, 12 Nov 2024 01:17:03 -0300 Subject: [PATCH] Add the "preloadData" prop - update tests - update README --- README.md | 22 ++- src/components/Devices.tsx | 1 - src/components/Info.tsx | 1 - src/constants.ts | 9 ++ src/index.tsx | 80 ++++++----- src/modules/getters.ts | 135 +++++++++++++++++- src/modules/helpers.ts | 52 +------ src/modules/hooks.ts | 4 +- src/modules/spotify.ts | 85 +++++++++-- src/types/common.ts | 6 +- test/__snapshots__/constants.spec.ts.snap | 21 +++ test/constants.spec.ts | 20 ++- test/fixtures/data.ts | 103 +++++++++++++ test/index.spec.tsx | 32 ++++- .../__snapshots__/getters.spec.ts.snap | 81 ++++++++++- test/modules/getters.spec.ts | 85 ++++++++++- test/modules/helpers.spec.ts | 8 +- test/modules/spotify.spec.ts | 67 ++++++++- vitest.config.mts | 4 + 19 files changed, 701 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index 9df2d1d..ddd967a 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,9 @@ Save the device selection. **play** `boolean` Control the player's status. +**preloadData** `boolean` +Preload the track data before playing. + **showSaveIcon** `boolean` ▶︎ false Display a Favorite button. It needs additional scopes in your token. @@ -226,7 +229,7 @@ Display a Favorite button. It needs additional scopes in your token. Customize the player's appearance. Check `StylesOptions` in the [types](src/types/common.ts). **syncExternalDevice** `boolean` ▶︎ false -If there are no URIs and an external device is playing, use the external player context. +Use the external player context if there are no URIs and an external device is playing. **syncExternalDeviceInterval** `number` ▶︎ 5 The time in seconds that the player will sync with external devices. @@ -252,12 +255,24 @@ import { spotifyApi } from 'react-spotify-web-playback'; **checkTracksStatus(token: string, tracks: string | string[]): Promise\** +**getAlbumTracks(token: string, id: string): Promise\** + +**getArtistTopTracks(token: string, id: string): Promise\** + **getDevices(token: string): Promise\** **getPlaybackState(token: string): Promise\** +**getPlaylistTracks(token: string, id: string): Promise\** + **getQueue(token: string): Promise\** +**getShow(token: string, id: string): Promise\** + +**getShowEpisodes(token: string, id: string, offset = 0): Promise\** + +**getTrack(token: string, id: string): Promise\** + **pause(token: string, deviceId?: string): Promise\** **play(token: string, options: SpotifyPlayOptions): Promise\** @@ -293,7 +308,7 @@ interface SpotifyPlayOptions { You can customize the UI with a `styles` prop. If you want a transparent player, you can use `bgColor: 'transparent'`. -Check all the available options [here](src/types/common.ts#L188). +Check all the available options [here](src/types/common.ts#L195). ```tsx ``` -![rswp-styles](https://gilbarbara.com/files/rswp-styles-e4060ddf.png) +![rswp-styles](https://files.gilbarbara.dev/media/rswp-v2.png) + ## Issues diff --git a/src/components/Devices.tsx b/src/components/Devices.tsx index 8751b8f..0cb8bea 100644 --- a/src/components/Devices.tsx +++ b/src/components/Devices.tsx @@ -189,7 +189,6 @@ export default function Devices(props: Props) { const handleClickSetDevice = (event: MouseEvent) => { const { dataset } = event.currentTarget; - /* istanbul ignore else */ if (dataset.id) { onClickDevice(dataset.id); diff --git a/src/components/Info.tsx b/src/components/Info.tsx index bfde554..d725085 100644 --- a/src/components/Info.tsx +++ b/src/components/Info.tsx @@ -296,7 +296,6 @@ function Info(props: Props) { const title = getSpotifyLinkTitle(name, locale.title); let favorite; - /* istanbul ignore else */ if (showSaveIcon && id) { favorite = (