Skip to content

Commit 3dd3c2f

Browse files
committed
fix(shuffle+): use PlatformAPI for Rootlist
Fixes #3656
1 parent a49b5a6 commit 3dd3c2f

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

Extensions/shuffle+.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
throw "";
2424
} catch {
2525
Spicetify.LocalStorage.set("shufflePlus:settings", "{}");
26-
return { artistMode: "all", artistNameMust: false, enableQueueButton: false };
26+
return {
27+
artistMode: "all",
28+
artistNameMust: false,
29+
enableQueueButton: false,
30+
};
2731
}
2832
}
2933

@@ -121,7 +125,10 @@
121125
onclickFun();
122126
},
123127
},
124-
React.createElement(DisplayIcon, { icon: Spicetify.SVGIcons.check, size: 16 })
128+
React.createElement(DisplayIcon, {
129+
icon: Spicetify.SVGIcons.check,
130+
size: 16,
131+
})
125132
)
126133
)
127134
);
@@ -299,30 +306,28 @@
299306

300307
function searchFolder(rows, uri) {
301308
for (const r of rows) {
302-
if (r.type !== "folder" || !r.rows) continue;
309+
if (r.type !== "folder" || !r.items) continue;
303310

304-
if (r.link === uri) return r;
311+
if (r.uri === uri) return r;
305312

306-
const found = searchFolder(r.rows, uri);
313+
const found = searchFolder(r.items, uri);
307314
if (found) return found;
308315
}
309316
}
310317

311318
async function fetchFolderTracks(uri) {
312-
const res = await Spicetify.CosmosAsync.get("sp://core-playlist/v1/rootlist", {
313-
policy: { folder: { rows: true, link: true } },
314-
});
319+
const res = await Spicetify.Platform.RootlistAPI.getContents();
315320

316-
const requestFolder = searchFolder(res.rows, uri);
321+
const requestFolder = searchFolder(res.items, uri);
317322
if (!requestFolder) throw "Cannot find folder";
318323

319324
const requestPlaylists = [];
320325
async function fetchNested(folder) {
321-
if (!folder.rows) return;
326+
if (!folder.items) return;
322327

323-
for (const i of folder.rows) {
328+
for (const i of folder.items) {
324329
if (i.type === "playlist") {
325-
const uriObj = Spicetify.URI.fromString(i.link);
330+
const uriObj = Spicetify.URI.fromString(i.uri);
326331
const uri = uriObj._base62Id ?? uriObj.id;
327332
requestPlaylists.push(await fetchPlaylistTracks(uri));
328333
} else if (i.type === "folder") await fetchNested(i);
@@ -336,7 +341,11 @@
336341

337342
async function fetchAlbumTracks(uri, includeMetadata = false) {
338343
const { queryAlbumTracks } = Spicetify.GraphQL.Definitions;
339-
const { data, errors } = await Spicetify.GraphQL.Request(queryAlbumTracks, { uri, offset: 0, limit: 100 });
344+
const { data, errors } = await Spicetify.GraphQL.Request(queryAlbumTracks, {
345+
uri,
346+
offset: 0,
347+
limit: 100,
348+
});
340349

341350
if (errors) throw errors[0].message;
342351
if (data.albumUnion.playability.playable === false) throw "Album is not playable";
@@ -540,7 +549,10 @@
540549

541550
if (context) {
542551
const { sessionId } = Spicetify.Platform.PlayerAPI.getState();
543-
Spicetify.Platform.PlayerAPI.updateContext(sessionId, { uri: context, url: `context://${context}` });
552+
Spicetify.Platform.PlayerAPI.updateContext(sessionId, {
553+
uri: context,
554+
url: `context://${context}`,
555+
});
544556
}
545557

546558
Spicetify.Player.next();

0 commit comments

Comments
 (0)