fix reanimated
This commit is contained in:
parent
a6156a928e
commit
c288bc735e
3 changed files with 58 additions and 20 deletions
|
|
@ -1,9 +1,13 @@
|
|||
{
|
||||
"authors": [
|
||||
{
|
||||
"name": "pylix",
|
||||
"id": "492949202121261067"
|
||||
}
|
||||
],
|
||||
"main": "src/index.ts"
|
||||
"authors": [
|
||||
{
|
||||
"name": "pylix",
|
||||
"id": "492949202121261067"
|
||||
},
|
||||
{
|
||||
"name": "forked by kmmiio99o",
|
||||
"id": "879393496627306587"
|
||||
}
|
||||
],
|
||||
"main": "src/index.ts"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ import { plugin } from "@vendetta";
|
|||
import { FluxDispatcher } from "@vendetta/metro/common";
|
||||
import { getAssetIDByName } from "@vendetta/ui/assets";
|
||||
import { showToast } from "@vendetta/ui/toasts";
|
||||
import { React } from "@vendetta/metro/common";
|
||||
import { View } from "react-native";
|
||||
import { Forms } from "@vendetta/ui/components";
|
||||
|
||||
import { lazy } from "react";
|
||||
import { LFMSettings } from "../../defs";
|
||||
|
|
@ -9,6 +12,8 @@ import Constants from "./constants";
|
|||
import { initialize, stop } from "./manager";
|
||||
import { UserStore } from "./modules";
|
||||
|
||||
const { FormText } = Forms;
|
||||
|
||||
export const pluginState = {
|
||||
pluginStopped: false,
|
||||
lastActivity: undefined,
|
||||
|
|
@ -38,7 +43,22 @@ export const currentSettings = new Proxy(plugin.storage, {
|
|||
},
|
||||
});
|
||||
|
||||
const LazySettings = lazy(() => import("./ui/pages/Settings"));
|
||||
// Wrap Settings component in error boundary
|
||||
const Settings = lazy(() =>
|
||||
import("./ui/pages/Settings").catch((err) => {
|
||||
console.error("[Last.fm] Failed to load settings:", err);
|
||||
return {
|
||||
default: () => (
|
||||
<View style={{ padding: 16 }}>
|
||||
<FormText style={{ color: "#ED4245" }}>
|
||||
Failed to load Last.fm settings. Please check your connection and
|
||||
reload Discord.
|
||||
</FormText>
|
||||
</View>
|
||||
),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
// Connection status tracking
|
||||
let connectionAttempts = 0;
|
||||
|
|
@ -63,7 +83,19 @@ async function tryInitialize() {
|
|||
}
|
||||
|
||||
export default {
|
||||
settings: LazySettings,
|
||||
settings: () => (
|
||||
<View style={{ flex: 1 }}>
|
||||
<React.Suspense
|
||||
fallback={
|
||||
<View style={{ padding: 16 }}>
|
||||
<FormText>Loading Last.fm settings...</FormText>
|
||||
</View>
|
||||
}
|
||||
>
|
||||
<Settings />
|
||||
</React.Suspense>
|
||||
</View>
|
||||
),
|
||||
onLoad() {
|
||||
pluginState.pluginStopped = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { useProxy } from "@vendetta/storage";
|
|||
import { getAssetIDByName } from "@vendetta/ui/assets";
|
||||
import { showToast } from "@vendetta/ui/toasts";
|
||||
import { React } from "@vendetta/metro/common";
|
||||
import { ScrollView } from "react-native";
|
||||
import { View } from "react-native";
|
||||
|
||||
import { currentSettings, pluginState } from "../..";
|
||||
import Constants from "../../constants";
|
||||
|
|
@ -37,8 +37,6 @@ export default function Settings() {
|
|||
try {
|
||||
await lastfmClient.fetchLatestScrobble();
|
||||
showToast("Connection successful!", getAssetIDByName("Check"));
|
||||
|
||||
// Reinitialize the plugin with new settings
|
||||
await initialize();
|
||||
} catch (error) {
|
||||
showToast(
|
||||
|
|
@ -51,7 +49,7 @@ export default function Settings() {
|
|||
};
|
||||
|
||||
return (
|
||||
<ScrollView style={{ flex: 1 }}>
|
||||
<View style={{ flex: 1 }}>
|
||||
<FormSection title="Account Settings">
|
||||
<FormInput
|
||||
title="Last.fm Username"
|
||||
|
|
@ -67,7 +65,7 @@ export default function Settings() {
|
|||
onChange={(value: string) => saveSettings("apiKey", value)}
|
||||
secureTextEntry={true}
|
||||
/>
|
||||
<FormText style={{ padding: 8, opacity: 0.5 }}>
|
||||
<FormText style={{ padding: 10, opacity: 0.5 }}>
|
||||
Get your API key at: https://www.last.fm/api/account/create
|
||||
</FormText>
|
||||
<FormRow
|
||||
|
|
@ -177,16 +175,20 @@ export default function Settings() {
|
|||
</FormSection>
|
||||
|
||||
<FormSection title="Plugin Status">
|
||||
<FormText style={{ padding: 8 }}>
|
||||
Status: {pluginState.pluginStopped ? "Stopped" : "Running"}
|
||||
{"\n"}
|
||||
Last Update: {pluginState.lastTrackUrl ? "Success" : "No track data"}
|
||||
</FormText>
|
||||
<View style={{ padding: 10 }}>
|
||||
<FormText>
|
||||
Status: {pluginState.pluginStopped ? "Stopped" : "Running"}
|
||||
</FormText>
|
||||
<FormText>
|
||||
Last Update:{" "}
|
||||
{pluginState.lastTrackUrl ? "Success" : "No track data"}
|
||||
</FormText>
|
||||
</View>
|
||||
</FormSection>
|
||||
|
||||
<FormText style={{ padding: 16, opacity: 0.5, textAlign: "center" }}>
|
||||
Version 2.0.0
|
||||
</FormText>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue