From f94ca62a41c0adbaf952e20b5d2e371a370c7c52 Mon Sep 17 00:00:00 2001
From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com>
Date: Mon, 13 Feb 2023 21:48:12 +0800
Subject: [PATCH] Last.fm: add update interval option
---
build.mjs | 6 +++++-
plugins/Last.fm/src/Settings.tsx | 13 +++++++++++--
plugins/Last.fm/src/utils.ts | 4 ++--
plugins/MoreConfirm/manifest.json | 2 +-
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/build.mjs b/build.mjs
index 9cba30e..e2f887d 100644
--- a/build.mjs
+++ b/build.mjs
@@ -24,7 +24,11 @@ let failed = 0;
await Promise.allSettled(toBuild.map(x => buildPlugin(x).catch(() => failed++)));
-console.log("\nDone! " + (failed ? "\x1b[31m" + `Failed to build ${failed} plugin${failed === 1 ? "" : "s"}` + "\x1b[0m" : "\x1b[32m" + "All plugins built successfully!" + "\x1b[0m"));
+console.log("\nDone! " + (
+ failed
+ ? "\x1b[31m" + `Failed to build ${failed} plugin${failed === 1 ? "" : "s"}` + "\x1b[0m"
+ : "\x1b[32m" + "All plugins built successfully!" + "\x1b[0m"
+));
if (!isWatch) process.exit(0);
else console.log("\nWatching for changes...");
diff --git a/plugins/Last.fm/src/Settings.tsx b/plugins/Last.fm/src/Settings.tsx
index 61f8bd3..85e3198 100644
--- a/plugins/Last.fm/src/Settings.tsx
+++ b/plugins/Last.fm/src/Settings.tsx
@@ -15,7 +15,7 @@ const { FormInput, FormDivider, FormSwitchRow, FormText, FormIcon } = Forms;
function UpdateButton() {
async function onPressCallback() {
for (const key in storage) {
- if (typeof storage[key] === "boolean" || storage[key]) {
+ if (storage[key] !== false && !storage[key]) {
currentSettings[key] = storage[key];
}
}
@@ -27,7 +27,7 @@ function UpdateButton() {
}
return
- {"UPDATE"}
+ UPDATE
;
}
@@ -61,6 +61,15 @@ export default function Settings() {
returnKeyType="done"
/>
+ settings.timeInterval = Number(value)}
+ title="Update interval (in seconds)"
+ placeholder={Constants.DEFAULT_TIME_INTERVAL.toString()}
+ keyboardType="numeric"
+ returnKeyType="done"
+ />
+
{
name: lastTrack.name,
artist: lastTrack.artist.name,
album: lastTrack.album["#text"],
- albumArt: handleAlbumCover(lastTrack.image[3]["#text"]),
+ albumArt: await handleAlbumCover(lastTrack.image[3]["#text"]),
url: lastTrack.url,
date: lastTrack.date?.["#text"] ?? "now",
nowPlaying: Boolean(lastTrack["@attr"]?.nowplaying),
@@ -37,7 +37,7 @@ async function fetchLatestScrobble(): Promise