diff --git a/plugins/Last.fm/src/index.tsx b/plugins/Last.fm/src/index.tsx index 6b5e5c4..819c427 100644 --- a/plugins/Last.fm/src/index.tsx +++ b/plugins/Last.fm/src/index.tsx @@ -43,29 +43,28 @@ export const currentSettings = new Proxy(plugin.storage, { }, }); +// Simple Settings component for fallback +function FallbackSettings() { + return ( + + + Failed to load Last.fm settings. Please check your connection and reload + Discord. + + + ); +} + // Settings component with error handling -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. - - - ), - }; - }), -); +const Settings = lazy(async () => { + try { + const module = await import("./ui/pages/Settings"); + return { default: module.default || FallbackSettings }; + } catch (err) { + console.error("[Last.fm] Failed to load settings:", err); + return { default: FallbackSettings }; + } +}); // Connection status tracking let connectionAttempts = 0; @@ -89,20 +88,8 @@ async function tryInitialize() { } } -export default { - settings: () => ( - - Loading Last.fm settings... - - } - > - - - ), +// Create the plugin object +const pluginObj = { onLoad() { pluginState.pluginStopped = false; @@ -143,3 +130,24 @@ export default { } }, }; + +// Add settings property to the plugin object +Object.defineProperty(pluginObj, "settings", { + get: () => ( + + Loading Last.fm settings... + + } + > + + + ), + enumerable: true, + configurable: true, +}); + +export default pluginObj; diff --git a/plugins/Last.fm/src/ui/pages/Settings.tsx b/plugins/Last.fm/src/ui/pages/Settings.tsx index e01f6e0..c4af342 100644 --- a/plugins/Last.fm/src/ui/pages/Settings.tsx +++ b/plugins/Last.fm/src/ui/pages/Settings.tsx @@ -25,7 +25,7 @@ const get = (k: string, fallback: any = "") => plugin.storage[k] ?? fallback; const set = (k: string, v: any) => (plugin.storage[k] = v); // Define the Settings component -function SettingsComponent() { +export default function Settings() { const [_, forceUpdate] = React.useReducer((x) => ~x, 0); const update = () => forceUpdate(); @@ -212,16 +212,3 @@ function SettingsComponent() { ); } - -// Export the settings component wrapped in Suspense -export const settings = () => ( - - Loading Last.fm settings... - - } - > - - -);