import { plugin } from "@vendetta"; import { storage } from "@vendetta/plugin"; import { useProxy } from "@vendetta/storage"; import { React } from "@vendetta/metro/common"; import { findByProps } from "@vendetta/metro"; import { View } from "react-native"; import { alerts } from "@vendetta/ui"; const { ScrollView } = findByProps("ScrollView"); const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps( "TableSwitchRow", "TableRowGroup", "Stack", "TableRow", ); // Initialize storage with default values if (!storage.factSettings) { storage.factSettings = { sendAsReply: true, includeCitation: false, }; } if (!storage.listSettings) { storage.listSettings = { pluginListAlwaysDetailed: false, themeListAlwaysDetailed: false, }; } if (!storage.enabledCommands) { storage.enabledCommands = { catfact: true, dogfact: true, useless: true, petpet: true, pluginList: true, themeList: true, konoself: true, konosend: true, }; } if (!storage.pendingRestart) { storage.pendingRestart = false; } export default function Settings() { useProxy(storage); const [rerender, forceRerender] = React.useReducer((x) => x + 1, 0); // Check for pending restart when unmounting React.useEffect(() => { return () => { if (storage.pendingRestart) { storage.pendingRestart = false; alerts.showConfirmationAlert({ title: "Restart Required", content: "You have made changes to commands. Please restart Discord to apply these changes.", confirmText: "Okay", cancelText: null, }); } }; }, []); const handleCommandToggle = (commandName: string, value: boolean) => { storage.enabledCommands[commandName] = value; storage.pendingRestart = true; forceRerender(); }; return ( {/* Facts Commands */} { storage.factSettings.sendAsReply = v; forceRerender(); }} /> { storage.factSettings.includeCitation = v; forceRerender(); }} /> handleCommandToggle("catfact", v)} /> handleCommandToggle("dogfact", v)} /> handleCommandToggle("useless", v)} /> {/* List Commands */} { storage.listSettings.pluginListAlwaysDetailed = v; forceRerender(); }} /> { storage.listSettings.themeListAlwaysDetailed = v; forceRerender(); }} /> handleCommandToggle("pluginList", v)} /> handleCommandToggle("themeList", v)} /> {/* Image Commands */} handleCommandToggle("petpet", v)} /> {/* KonoChan Commands */} handleCommandToggle("konoself", v)} /> handleCommandToggle("konosend", v)} /> {/* Credits */} {/* About */} ); }