Replace usage of null with undefined.
This commit is contained in:
parent
8c8c8970d8
commit
2d2778df9d
|
@ -40,24 +40,24 @@ async function getCurrentListen() {
|
||||||
const result = await window.fetch('https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now');
|
const result = await window.fetch('https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now');
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
console.warn(result.status);
|
console.warn(result.status);
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await result.json();
|
const data = await result.json();
|
||||||
if (data.payload.listens.length === 0) {
|
if (data.payload.listens.length === 0) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.payload.listens[0];
|
return data.payload.listens[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertHtml(listen, image) {
|
function insertHtml(listen, image) {
|
||||||
if (listen === null) {
|
if (listen === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const existing = document.querySelector('.listenbrainz');
|
const existing = document.querySelector('.listenbrainz') ?? undefined;
|
||||||
if (existing !== null) {
|
if (existing !== undefined) {
|
||||||
existing.remove();
|
existing.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue