-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Pass location from listener to toggleButton function - Refactor - Move fetching functions to services.ts - Rename util.ts to utils.ts
- Loading branch information
Showing
7 changed files
with
41 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IAlbum, ISavedAlbums } from "./types/api"; | ||
|
||
export const getAlbumsCount = async (): Promise<number> => { | ||
const result: ISavedAlbums = await Spicetify.CosmosAsync.get( | ||
"https://api.spotify.com/v1/me/albums?limit=1", | ||
); | ||
|
||
return result.total; | ||
}; | ||
|
||
export const getRandomAlbum = async (total: number): Promise<IAlbum> => { | ||
const randomIndex = Math.floor(Math.random() * (total + 1)); | ||
|
||
const randomResult: ISavedAlbums = await Spicetify.CosmosAsync.get( | ||
`https://api.spotify.com/v1/me/albums?limit=1&offset=${randomIndex - 1}`, | ||
); | ||
|
||
return randomResult.items[0]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters