Add credits rows and improve restart prompt in settings

This commit is contained in:
kmmiio99o 2025-09-27 20:44:51 +02:00
parent 8a51bd5b6d
commit f84f55448c

View file

@ -8,10 +8,11 @@ import { View } from "react-native";
import { alerts } from "@vendetta/ui"; import { alerts } from "@vendetta/ui";
const { ScrollView } = findByProps("ScrollView"); const { ScrollView } = findByProps("ScrollView");
const { TableRowGroup, TableSwitchRow, Stack } = findByProps( const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps(
"TableSwitchRow", "TableSwitchRow",
"TableRowGroup", "TableRowGroup",
"Stack", "Stack",
"TableRow",
); );
// Initialize default settings if not exist // Initialize default settings if not exist
@ -42,29 +43,43 @@ if (!storage.enabledCommands) {
}; };
} }
const askForRestart = (commandName: string, enabled: boolean) => { if (!storage.pendingRestart) {
return alerts.showConfirmationAlert({ storage.pendingRestart = false;
title: "Restart Required", }
content: `${enabled ? "Enabling" : "Disabling"} the ${commandName} command requires a Discord restart to take effect. Would you like to restart now?`,
confirmText: "Restart", const Credits = {
cancelText: "Later", PETPET: "wolfieeee",
confirmColor: "brand", FACTS: "jdev082",
onConfirm: () => { LISTS: "Kitomanari",
storage.enabledCommands[commandName] = enabled; KONOCHAN: ["btmc727", "Rico040"],
window.enmity.plugins.reload("vendetta");
},
onCancel: () => {
storage.enabledCommands[commandName] = !enabled; // Revert change if user doesn't want to restart
},
});
}; };
export default function Settings() { export default function Settings() {
useProxy(storage); useProxy(storage);
const [rerender, forceRerender] = React.useReducer((x) => x + 1, 0); const [rerender, forceRerender] = React.useReducer((x) => x + 1, 0);
// Check for changes when component unmounts
React.useEffect(() => {
return () => {
if (storage.pendingRestart) {
alerts.showConfirmationAlert({
title: "Restart Required",
content:
"Command changes require Discord to restart. Would you like to restart now?",
confirmText: "Restart",
cancelText: "Later",
confirmColor: "brand",
onConfirm: () => {
window.enmity.plugins.reload("vendetta");
},
});
}
};
}, []);
const handleCommandToggle = (commandName: string, value: boolean) => { const handleCommandToggle = (commandName: string, value: boolean) => {
askForRestart(commandName, value); storage.enabledCommands[commandName] = value;
storage.pendingRestart = true;
forceRerender(); forceRerender();
}; };
@ -94,6 +109,11 @@ export default function Settings() {
forceRerender(); forceRerender();
}} }}
/> />
<TableRow
label="Credits"
subLabel={`Facts commands by ${Credits.FACTS}`}
icon={getAssetIDByName("ic_info")}
/>
<TableSwitchRow <TableSwitchRow
label="/catfact" label="/catfact"
subLabel="Get random cat facts" subLabel="Get random cat facts"
@ -117,7 +137,7 @@ export default function Settings() {
/> />
</TableRowGroup> </TableRowGroup>
{/* List Commands Settings */} {/* List Commands */}
<TableRowGroup title="List Commands"> <TableRowGroup title="List Commands">
<TableSwitchRow <TableSwitchRow
label="Always Send Detailed Plugin List" label="Always Send Detailed Plugin List"
@ -139,6 +159,11 @@ export default function Settings() {
forceRerender(); forceRerender();
}} }}
/> />
<TableRow
label="Credits"
subLabel={`List commands by ${Credits.LISTS}`}
icon={getAssetIDByName("ic_info")}
/>
<TableSwitchRow <TableSwitchRow
label="/plugin-list" label="/plugin-list"
subLabel="List all installed plugins" subLabel="List all installed plugins"
@ -157,6 +182,11 @@ export default function Settings() {
{/* Image Commands */} {/* Image Commands */}
<TableRowGroup title="Image Commands"> <TableRowGroup title="Image Commands">
<TableRow
label="Credits"
subLabel={`PetPet command by ${Credits.PETPET}`}
icon={getAssetIDByName("ic_info")}
/>
<TableSwitchRow <TableSwitchRow
label="/petpet" label="/petpet"
subLabel="Create pet-pet GIF of a user" subLabel="Create pet-pet GIF of a user"
@ -168,6 +198,11 @@ export default function Settings() {
{/* KonoChan Commands */} {/* KonoChan Commands */}
<TableRowGroup title="KonoChan Commands"> <TableRowGroup title="KonoChan Commands">
<TableRow
label="Credits"
subLabel={`KonoChan commands by ${Credits.KONOCHAN.join(" & ")}`}
icon={getAssetIDByName("ic_info")}
/>
<TableSwitchRow <TableSwitchRow
label="/konoself" label="/konoself"
subLabel="Get random image from KonoChan (private)" subLabel="Get random image from KonoChan (private)"
@ -186,12 +221,10 @@ export default function Settings() {
{/* About Section */} {/* About Section */}
<TableRowGroup title="About"> <TableRowGroup title="About">
<TableSwitchRow <TableRow
label="All-In-One Commands" label="All-In-One Commands"
subLabel="A collection of useful commands" subLabel="A collection of useful commands"
icon={getAssetIDByName("ic_badge_staff")} icon={getAssetIDByName("ic_badge_staff")}
value={true}
disabled={true}
/> />
</TableRowGroup> </TableRowGroup>
</Stack> </Stack>