Skip to content

Commit 51e9cb1

Browse files
committed
fix: use try catch block
1 parent c2d2ef3 commit 51e9cb1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

jsHelper/spicetifyWrapper.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,21 +326,21 @@ window.Spicetify = {
326326
setTimeout(addMissingPlatformAPIs, 50);
327327
return;
328328
}
329-
const version = Spicetify.Platform.version.split(".").map((i) => Number.parseInt(i));
329+
const version = Spicetify.Platform.version.split(".").map((i) => Number.parseInt(i, 10));
330330
if (version[0] === 1 && version[1] === 2 && version[2] < 38) return;
331331

332332
for (const [key, _] of Spicetify.Platform.Registry._map.entries()) {
333333
if (typeof key?.description !== "string" || !key?.description.endsWith("API")) continue;
334334
const symbolName = key.description;
335335
if (Object.hasOwn(Spicetify.Platform, symbolName)) continue;
336-
const resolvedAPI = Spicetify.Platform.Registry.resolve(key);
337-
if (!resolvedAPI) {
338-
console.warn(`[spicetifyWrapper] Failed to resolve PlatformAPI from Registry: ${symbolName}`);
339-
continue;
340-
}
336+
try {
337+
const resolvedAPI = Spicetify.Platform.Registry.resolve(key);
338+
Spicetify.Platform[symbolName] = resolvedAPI;
341339

342-
Spicetify.Platform[symbolName] = resolvedAPI;
343-
console.debug(`[spicetifyWrapper] Resolved PlatformAPI from Registry: ${symbolName}`);
340+
console.debug(`[spicetifyWrapper] Resolved PlatformAPI from Registry: ${symbolName}`);
341+
} catch (err) {
342+
console.error(`[spicetifyWrapper] Error resolving PlatformAPI from Registry: ${symbolName}`, err);
343+
}
344344
}
345345
})();
346346

@@ -352,7 +352,7 @@ function applyScrollingFix() {
352352
}
353353

354354
// Run only for 1.2.56 and lower
355-
const version = Spicetify.Platform.version.split(".").map((i) => Number.parseInt(i));
355+
const version = Spicetify.Platform.version.split(".").map((i) => Number.parseInt(i, 10));
356356
if (version[1] >= 2 && version[2] >= 57) return;
357357

358358
const scrollableElements = Array.from(document.querySelectorAll("*")).filter((el) => {
@@ -1368,7 +1368,7 @@ Spicetify._getStyledClassName = (args, component) => {
13681368
"[": "[",
13691369
"\\": "\\",
13701370
"]": "]",
1371-
// biome-ignore lint/suspicious/noDuplicateObjectKeys: <explanation>
1371+
// biome-ignore lint/suspicious/noDuplicateObjectKeys: Not an issue
13721372
'"': '"',
13731373
"~": "`",
13741374
"!": "1",

0 commit comments

Comments
 (0)