Last.fm: fix async function
This commit is contained in:
parent
85ef273cde
commit
c86e190274
3 changed files with 10 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
export default {
|
||||
const Constants = {
|
||||
DEFAULT_APP_NAME: "Music",
|
||||
/** The application ID of the plugin */
|
||||
APPLICATION_ID: "1054951789318909972",
|
||||
/** Last.fm api key */
|
||||
|
|
@ -9,3 +10,5 @@ export default {
|
|||
"c6f59c1e5e7240a4c0d427abd71f3dbb",
|
||||
]
|
||||
} as const;
|
||||
|
||||
export default Constants;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { getAssetIDByName } from "@vendetta/ui/assets";
|
|||
import { Forms } from "@vendetta/ui/components";
|
||||
|
||||
import { currentSettings } from ".";
|
||||
import Constants from "./constants";
|
||||
import { flush, initialize } from "./utils";
|
||||
|
||||
const { ScrollView, TouchableOpacity, Text } = ReactNative;
|
||||
|
|
@ -39,7 +40,7 @@ export default function Settings() {
|
|||
value={settings.appName || undefined}
|
||||
onChangeText={(value: string) => settings.appName = value.trim()}
|
||||
title="Discord Application Name"
|
||||
placeholder="Music"
|
||||
placeholder={Constants.DEFAULT_APP_NAME}
|
||||
returnKeyType="done"
|
||||
/>
|
||||
<FormDivider />
|
||||
|
|
|
|||
|
|
@ -83,11 +83,11 @@ export async function update() {
|
|||
|
||||
if (!currentSettings.username) {
|
||||
showToast("Last.fm username is not set!", getAssetIDByName("Small"));
|
||||
await flush(); // Flush as we always needs reinitialization
|
||||
await flush(); // Flush as we always need reinitialization
|
||||
throw new Error("Username is not set");
|
||||
}
|
||||
|
||||
const lastTrack = await fetchLatestScrobble().catch(async (err) => {
|
||||
const lastTrack = await fetchLatestScrobble().catch(async function (err) {
|
||||
verboseLog("--> An error occurred while fetching the last track, aborting...");
|
||||
await clearActivity().catch();
|
||||
throw err;
|
||||
|
|
@ -106,7 +106,7 @@ export async function update() {
|
|||
}
|
||||
|
||||
const activity = {
|
||||
name: currentSettings.appName || "Music",
|
||||
name: currentSettings.appName || Constants.DEFAULT_APP_NAME,
|
||||
type: currentSettings.listeningTo ? 2 : 0,
|
||||
details: lastTrack.name,
|
||||
state: `by ${lastTrack.artist}`,
|
||||
|
|
@ -128,7 +128,7 @@ export async function update() {
|
|||
}
|
||||
}
|
||||
|
||||
const response = await sendRequest(activity).catch(async (err) => {
|
||||
const response = await sendRequest(activity).catch(async function (err) {
|
||||
verboseLog("--> An error occurred while setting the activity");
|
||||
await clearActivity().catch();
|
||||
throw err;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue