feat: detach Sidebar patches as they
causes crash on settings page on newest alpha
This commit is contained in:
parent
59f239f7c1
commit
ecd97c7018
4 changed files with 4 additions and 80 deletions
|
|
@ -26,7 +26,6 @@ import {
|
|||
friendInviteRevokeCommand,
|
||||
} from "./src/commands/friendinvites";
|
||||
import settings from "./settings/settings";
|
||||
import patchSidebar from "./sidebar";
|
||||
|
||||
if (!storage.factSettings) {
|
||||
storage.factSettings = {
|
||||
|
|
@ -77,10 +76,6 @@ if (!storage.hiddenSettings) {
|
|||
konochanBypassNsfw: false,
|
||||
};
|
||||
}
|
||||
// sidebar enabled setting
|
||||
if (storage.sidebarEnabled === undefined) {
|
||||
storage.sidebarEnabled = true;
|
||||
}
|
||||
|
||||
const commandMap = {
|
||||
catfact: catFactCommand,
|
||||
|
|
@ -107,22 +102,11 @@ const commandMap = {
|
|||
};
|
||||
|
||||
let commands: Array<() => void> = [];
|
||||
let sidebarUnpatch: (() => void) | undefined;
|
||||
|
||||
export default {
|
||||
onLoad: () => {
|
||||
console.log("[Commands Plugin] Loading...");
|
||||
|
||||
// Patch sidebar if enabled
|
||||
if (storage.sidebarEnabled !== false) {
|
||||
try {
|
||||
sidebarUnpatch = patchSidebar();
|
||||
console.log("[Commands Plugin] Sidebar patched successfully");
|
||||
} catch (error) {
|
||||
console.error("[Commands Plugin] Failed to patch sidebar:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Register commands
|
||||
for (const [key, command] of Object.entries(commandMap)) {
|
||||
if (storage.enabledCommands[key]) {
|
||||
|
|
@ -150,17 +134,6 @@ export default {
|
|||
}
|
||||
});
|
||||
commands = [];
|
||||
|
||||
// Unpatch sidebar
|
||||
if (sidebarUnpatch) {
|
||||
try {
|
||||
sidebarUnpatch();
|
||||
sidebarUnpatch = undefined;
|
||||
console.log("[Commands Plugin] Sidebar unpatched");
|
||||
} catch (error) {
|
||||
console.error("[Commands Plugin] Failed to unpatch sidebar:", error);
|
||||
}
|
||||
}
|
||||
},
|
||||
settings,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ storage.hiddenSettings ??= {
|
|||
konochanBypassNsfw: false,
|
||||
};
|
||||
|
||||
// Sidebar setting (enabled by default)
|
||||
storage.sidebarEnabled ??= true;
|
||||
// Sidebar setting
|
||||
storage.sidebarEnabled ??= false;
|
||||
|
||||
// MAIN SETTINGS COMPONENT
|
||||
export default function Settings() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { UserStore } from "./modules";
|
|||
import { serviceFactory } from "./services/ServiceFactory";
|
||||
|
||||
import Settings from "./ui/pages/Settings";
|
||||
import patchSidebar from "./sidebar";
|
||||
|
||||
export const pluginState = {
|
||||
pluginStopped: false,
|
||||
|
|
@ -22,8 +21,6 @@ export const pluginState = {
|
|||
lastTrackUrl?: string;
|
||||
};
|
||||
|
||||
let sidebarUnpatch: (() => void) | undefined;
|
||||
|
||||
// Initialize default settings
|
||||
const defaultSettings: LFMSettings = Constants.DEFAULT_SETTINGS;
|
||||
Object.keys(defaultSettings).forEach((key) => {
|
||||
|
|
@ -31,8 +28,6 @@ Object.keys(defaultSettings).forEach((key) => {
|
|||
plugin.storage[key] ?? defaultSettings[key as keyof typeof defaultSettings];
|
||||
});
|
||||
|
||||
plugin.storage.addToSidebar ??= false;
|
||||
|
||||
export const currentSettings = new Proxy(plugin.storage, {
|
||||
get(target, prop: string) {
|
||||
return target[prop];
|
||||
|
|
@ -124,16 +119,6 @@ export default {
|
|||
console.log("[Multi-Scrobbler] Loading...");
|
||||
pluginState.pluginStopped = false;
|
||||
|
||||
// Patch sidebar if enabled
|
||||
if (currentSettings.addToSidebar !== false) {
|
||||
try {
|
||||
sidebarUnpatch = patchSidebar();
|
||||
console.log("[Multi-Scrobbler] Sidebar patched successfully");
|
||||
} catch (error) {
|
||||
console.error("[Multi-Scrobbler] Failed to patch sidebar:", error);
|
||||
}
|
||||
}
|
||||
|
||||
validateAndInitialize();
|
||||
},
|
||||
|
||||
|
|
@ -141,50 +126,15 @@ export default {
|
|||
console.log("[Multi-Scrobbler] Unloading...");
|
||||
pluginState.pluginStopped = true;
|
||||
|
||||
// Unpatch sidebar
|
||||
if (sidebarUnpatch) {
|
||||
try {
|
||||
sidebarUnpatch();
|
||||
sidebarUnpatch = undefined;
|
||||
console.log("[Multi-Scrobbler] Sidebar unpatched");
|
||||
} catch (error) {
|
||||
console.error("[Multi-Scrobbler] Failed to unpatch sidebar:", error);
|
||||
}
|
||||
}
|
||||
|
||||
stop();
|
||||
},
|
||||
|
||||
async onSettingsUpdate(newSettings: any) {
|
||||
const oldService = currentSettings.service;
|
||||
const newService = newSettings.service;
|
||||
const oldSidebar = currentSettings.addToSidebar;
|
||||
const newSidebar = newSettings.addToSidebar;
|
||||
|
||||
Object.assign(currentSettings, newSettings);
|
||||
|
||||
// Check if sidebar setting changed
|
||||
if (oldSidebar !== newSidebar) {
|
||||
if (newSidebar) {
|
||||
try {
|
||||
sidebarUnpatch = patchSidebar();
|
||||
console.log("[Multi-Scrobbler] Sidebar enabled");
|
||||
} catch (error) {
|
||||
console.error("[Multi-Scrobbler] Failed to enable sidebar:", error);
|
||||
}
|
||||
} else {
|
||||
if (sidebarUnpatch) {
|
||||
try {
|
||||
sidebarUnpatch();
|
||||
} catch (e) {
|
||||
console.error("[Multi-Scrobbler] Failed to unpatch sidebar:", e);
|
||||
}
|
||||
sidebarUnpatch = undefined;
|
||||
console.log("[Multi-Scrobbler] Sidebar disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oldService !== newService && newService) {
|
||||
console.log(`[Multi-Scrobbler] Service changed from ${oldService || "none"} to ${newService}`);
|
||||
try {
|
||||
|
|
@ -212,4 +162,4 @@ export default {
|
|||
},
|
||||
|
||||
settings: Settings,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ export default function Settings() {
|
|||
setStorage("addToSidebar", value);
|
||||
forceUpdate();
|
||||
}}
|
||||
disabled={true}
|
||||
/>
|
||||
</TableRowGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue