js fixes
This commit is contained in:
parent
c3fd191072
commit
a419f38024
4 changed files with 62 additions and 76 deletions
|
|
@ -69,10 +69,7 @@ export class LosslessAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
let errorData;
|
let errorData = await response.clone().json();
|
||||||
try {
|
|
||||||
errorData = await response.clone().json();
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
if (errorData?.subStatus === 11002) {
|
if (errorData?.subStatus === 11002) {
|
||||||
lastError = new Error(errorData?.userMessage || 'Authentication failed');
|
lastError = new Error(errorData?.userMessage || 'Authentication failed');
|
||||||
|
|
|
||||||
|
|
@ -166,12 +166,10 @@ export const apiSettings = {
|
||||||
async getInstances(type = 'api') {
|
async getInstances(type = 'api') {
|
||||||
let instancesObj;
|
let instancesObj;
|
||||||
|
|
||||||
try {
|
|
||||||
const stored = localStorage.getItem(this.STORAGE_KEY);
|
const stored = localStorage.getItem(this.STORAGE_KEY);
|
||||||
if (stored) {
|
if (stored) {
|
||||||
instancesObj = JSON.parse(stored);
|
instancesObj = JSON.parse(stored);
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (!instancesObj) {
|
if (!instancesObj) {
|
||||||
instancesObj = await this.loadInstancesFromGitHub();
|
instancesObj = await this.loadInstancesFromGitHub();
|
||||||
|
|
|
||||||
7
js/ui.js
7
js/ui.js
|
|
@ -1311,12 +1311,7 @@ export class UIRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render API playlist
|
// Render API playlist
|
||||||
let apiResult;
|
let apiResult = await this.api.getPlaylist(playlistId);
|
||||||
try {
|
|
||||||
apiResult = await this.api.getPlaylist(playlistId);
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { playlist, tracks } = apiResult;
|
const { playlist, tracks } = apiResult;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ export function getVibrantColorFromImage(imgElement) {
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
if (!ctx) return null;
|
if (!ctx) return null;
|
||||||
|
|
||||||
try {
|
|
||||||
const maxDimension = 64;
|
const maxDimension = 64;
|
||||||
let w = imgElement.naturalWidth || imgElement.width;
|
let w = imgElement.naturalWidth || imgElement.width;
|
||||||
let h = imgElement.naturalHeight || imgElement.height;
|
let h = imgElement.naturalHeight || imgElement.height;
|
||||||
|
|
@ -145,7 +144,4 @@ export function getVibrantColorFromImage(imgElement) {
|
||||||
const best = candidates[0];
|
const best = candidates[0];
|
||||||
|
|
||||||
return hslToHex(best.h, best.s, best.l);
|
return hslToHex(best.h, best.s, best.l);
|
||||||
} catch (e) {
|
|
||||||
throw e; // Re-throw to allow UI to handle CORS retry
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue