This commit is contained in:
AntonMacG 2023-11-13 10:12:31 +00:00
parent 0e494fc22b
commit 400e9705e5

View file

@ -24,10 +24,12 @@ export const settings = definePluginSettings({
default: "", default: "",
disabled: () => settings.store.alwaysPingOnReply, disabled: () => settings.store.alwaysPingOnReply,
onChange: newValue => { onChange: newValue => {
cachedWhitelist = parseWhitelist(newValue); const newWhitelist = parseWhitelist(newValue);
if (!validateWhitelist(newValue)) {
if (newWhitelist.length === 0 && newValue.trim() !== "") {
showToast("Invalid User ID: One or more User IDs in the whitelist are invalid. Please check your input."); showToast("Invalid User ID: One or more User IDs in the whitelist are invalid. Please check your input.");
} else { } else {
cachedWhitelist = newWhitelist;
showToast("Whitelist Updated: Reply ping whitelist has been successfully updated."); showToast("Whitelist Updated: Reply ping whitelist has been successfully updated.");
} }
} }
@ -73,16 +75,6 @@ export default definePlugin({
}, },
}); });
function validateWhitelist(value: string) {
const whitelist = parseWhitelist(value);
if (whitelist.length === 0 && value.trim() !== "") {
showToast("Invalid User ID: One or more User IDs in the whitelist are invalid. Please check your input.");
return false;
}
showToast("Whitelist Updated: Reply ping whitelist has been successfully updated.");
return true;
}
function parseWhitelist(value: string) { function parseWhitelist(value: string) {
return value.split(",") return value.split(",")
.map(id => id.trim()) .map(id => id.trim())