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: "",
disabled: () => settings.store.alwaysPingOnReply,
onChange: newValue => {
cachedWhitelist = parseWhitelist(newValue);
if (!validateWhitelist(newValue)) {
const newWhitelist = parseWhitelist(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.");
} else {
cachedWhitelist = newWhitelist;
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) {
return value.split(",")
.map(id => id.trim())