From 90420a2512cd68781dff73b6d695ca0674ed77ed Mon Sep 17 00:00:00 2001
From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com>
Date: Fri, 19 Sep 2025 21:39:56 +0200
Subject: [PATCH] factor V4
---
plugins/Last.fm/src/index.tsx | 45 ++++++++++++++---------
plugins/Last.fm/src/ui/pages/Settings.tsx | 39 +++++++-------------
2 files changed, 40 insertions(+), 44 deletions(-)
diff --git a/plugins/Last.fm/src/index.tsx b/plugins/Last.fm/src/index.tsx
index effb3ac..6b5e5c4 100644
--- a/plugins/Last.fm/src/index.tsx
+++ b/plugins/Last.fm/src/index.tsx
@@ -3,7 +3,7 @@ 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 { ScrollView } from "react-native";
+import { ScrollView, View } from "react-native";
import { Forms } from "@vendetta/ui/components";
import { lazy } from "react";
@@ -44,20 +44,27 @@ export const currentSettings = new Proxy(plugin.storage, {
});
// Settings component with error handling
-const Settings = lazy(() =>
- import("./ui/pages/Settings").catch((err) => {
- console.error("[Last.fm] Failed to load settings:", err);
- return {
- default: () => (
-
-
- Failed to load Last.fm settings. Please check your connection and
- reload Discord.
-
-
- ),
- };
- }),
+const SettingsComponent = lazy(() =>
+ import("./ui/pages/Settings")
+ .then((module) => ({
+ default: module.SettingsComponent,
+ }))
+ .catch((err) => {
+ console.error("[Last.fm] Failed to load settings:", err);
+ return {
+ default: () => (
+
+
+ Failed to load Last.fm settings. Please check your connection and
+ reload Discord.
+
+
+ ),
+ };
+ }),
);
// Connection status tracking
@@ -86,12 +93,14 @@ export default {
settings: () => (
+
Loading Last.fm settings...
-
+
}
>
-
+
),
onLoad() {
diff --git a/plugins/Last.fm/src/ui/pages/Settings.tsx b/plugins/Last.fm/src/ui/pages/Settings.tsx
index 4f7f07c..e01f6e0 100644
--- a/plugins/Last.fm/src/ui/pages/Settings.tsx
+++ b/plugins/Last.fm/src/ui/pages/Settings.tsx
@@ -24,7 +24,8 @@ import { lastfmClient } from "../../utils/lastfm";
const get = (k: string, fallback: any = "") => plugin.storage[k] ?? fallback;
const set = (k: string, v: any) => (plugin.storage[k] = v);
-function Settings() {
+// Define the Settings component
+function SettingsComponent() {
const [_, forceUpdate] = React.useReducer((x) => ~x, 0);
const update = () => forceUpdate();
@@ -212,29 +213,15 @@ function Settings() {
);
}
-export default {
- settings: () => (
-
- Loading Last.fm settings...
-
- }
- >
-
-
- ),
- onLoad() {
- pluginState.pluginStopped = false;
-
- if (!currentSettings.username || !currentSettings.apiKey) {
- showToast(
- "Please configure Last.fm username and API key in settings",
- getAssetIDByName("ic_warning"),
- );
- return;
+// Export the settings component wrapped in Suspense
+export const settings = () => (
+
+ Loading Last.fm settings...
+
}
- },
-};
+ >
+
+
+);