-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from jeroentvb/dev
feat: auto sync combined playlists at Spotify startup
- Loading branch information
Showing
12 changed files
with
2,094 additions
and
1,380 deletions.
There are no files selected for viewing
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
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,22 @@ | ||
import { LS_KEY } from '../constants'; | ||
import type { CombinedPlaylist } from '../types'; | ||
import { combinePlaylists, getCombinedPlaylistsSettings } from '../utils'; | ||
|
||
(async () => { | ||
while (!Spicetify?.Platform || !Spicetify?.CosmosAsync) { | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
} | ||
|
||
const autoSync = getCombinedPlaylistsSettings().autoSync; | ||
if (autoSync) synchronizeCombinedPlaylists(); | ||
})(); | ||
|
||
export function synchronizeCombinedPlaylists() { | ||
const combinedPlaylists: CombinedPlaylist[] = JSON.parse(Spicetify.LocalStorage.get(LS_KEY) as string) ?? []; | ||
|
||
return Promise.all(combinedPlaylists.map(({ sources, target }) => combinePlaylists(sources, target, true))) | ||
.catch((err) => { | ||
console.error('An error ocurred while auto-syncing playlists', err); | ||
Spicetify.showNotification('An error ocurred while auto-syncing playlists', true); | ||
}); | ||
} |
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,3 @@ | ||
export interface CombinedPlaylistsSettings { | ||
autoSync: boolean; | ||
} |
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,5 @@ | ||
export interface PlaylistRowsResponse { | ||
rows: { | ||
link: string | ||
}[] | ||
} |
Oops, something went wrong.
24f491d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this incredible new feature.!