Last.fm: add update interval option

This commit is contained in:
amsyarasyiq 2023-02-13 21:48:12 +08:00
parent d650820765
commit f94ca62a41
4 changed files with 19 additions and 6 deletions

View file

@ -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...");

View file

@ -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 <TouchableOpacity onPress={onPressCallback}>
<FormText style={{ marginRight: 12 }}>{"UPDATE"}</FormText>
<FormText style={{ marginRight: 12 }}>UPDATE</FormText>
</TouchableOpacity>;
}
@ -61,6 +61,15 @@ export default function Settings() {
returnKeyType="done"
/>
<FormDivider />
<FormInput
value={settings.timeInterval}
onChangeText={(value: string) => settings.timeInterval = Number(value)}
title="Update interval (in seconds)"
placeholder={Constants.DEFAULT_TIME_INTERVAL.toString()}
keyboardType="numeric"
returnKeyType="done"
/>
<FormDivider />
<FormSwitchRow
label="Show time elapsed"
subLabel="Show the time elapsed since the song started playing"

View file

@ -25,7 +25,7 @@ async function fetchLatestScrobble(): Promise<Track> {
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<Track> {
* Currently ditches the default album covers
* @param cover The album cover given by Last.fm
*/
function handleAlbumCover(cover: string): string {
async function handleAlbumCover(cover: string): Promise<string> {
// If the cover is a default one, return null (remove the cover)
if (Constants.LFM_DEFAULT_COVER_HASHES.some(x => cover.includes(x))) {
return null;

View file

@ -1,6 +1,6 @@
{
"name": "MoreConfirm",
"description": "Prompt comfirmations before making an irreversible actions.",
"description": "Prompts confirmations before making irreversible actions.",
"authors": [
{
"name": "amsyarasyiq",