1
Fork 0

Replace usage of null with undefined.

This commit is contained in:
Bauke 2022-03-28 15:18:16 +02:00
parent 8c8c8970d8
commit 2d2778df9d
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 5 additions and 5 deletions

View File

@ -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();
} }