Skip to content

Commit

Permalink
Add check URIs functions
Browse files Browse the repository at this point in the history
  • Loading branch information
SeitaHigashi committed May 8, 2021
1 parent f4612e2 commit 600fa2b
Showing 1 changed file with 22 additions and 37 deletions.
59 changes: 22 additions & 37 deletions Extensions/shuffle+.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@
if (headers.length > 0) clearInterval(iframeInterval);
}, 500)

const checkUris = (uris) => {
if (uris.length === 1) {
const uriObj = Spicetify.URI.fromString(uris[0]);
switch (uriObj.type) {
case Spicetify.URI.Type.SHOW:
case Spicetify.URI.Type.PLAYLIST:
case Spicetify.URI.Type.PLAYLIST_V2:
case Spicetify.URI.Type.FOLDER:
case Spicetify.URI.Type.ALBUM:
case Spicetify.URI.Type.COLLECTION:
case Spicetify.URI.Type.ARTIST:
return true;
}
return false;
}
// User selects multiple tracks in a list.
return true;
}


const cntxMenu = new Spicetify.ContextMenu.Item(
"Play with Shuffle+",
(uris) => {
Expand All @@ -102,24 +122,7 @@
const list = uris.map((uri) => ({ uri }));
playList(shuffle(list));
},
(uris) => {
if (uris.length === 1) {
const uriObj = Spicetify.URI.fromString(uris[0]);
switch (uriObj.type) {
case Spicetify.URI.Type.SHOW:
case Spicetify.URI.Type.PLAYLIST:
case Spicetify.URI.Type.PLAYLIST_V2:
case Spicetify.URI.Type.FOLDER:
case Spicetify.URI.Type.ALBUM:
case Spicetify.URI.Type.COLLECTION:
case Spicetify.URI.Type.ARTIST:
return true;
}
return false;
}
// User selects multiple tracks in a list.
return true;
},
checkUris,
"shuffle"
)
cntxMenu.register();
Expand All @@ -144,29 +147,11 @@
const list = uris.map((uri) => ({ uri }));
setQueue(shuffle(next_tracks.concat(list)));
},
(uris) => {
if (uris.length === 1) {
const uriObj = Spicetify.URI.fromString(uris[0]);
switch (uriObj.type) {
case Spicetify.URI.Type.SHOW:
case Spicetify.URI.Type.PLAYLIST:
case Spicetify.URI.Type.PLAYLIST_V2:
case Spicetify.URI.Type.FOLDER:
case Spicetify.URI.Type.ALBUM:
case Spicetify.URI.Type.COLLECTION:
case Spicetify.URI.Type.ARTIST:
return true;
}
return false;
}
// User selects multiple tracks in a list.
return true;
},
checkUris,
"shuffle"
)
cntxMenu2.register();


/**
*
* @param {string} uri
Expand Down

0 comments on commit 600fa2b

Please sign in to comment.