fix being able to delete first item

This commit is contained in:
camila314 2024-06-24 02:58:56 -05:00
parent 3b39564904
commit 0b20a2e211

View file

@ -60,6 +60,9 @@ function FlaggedInput({ index, forceUpdate }) {
}; };
const removeSelf = () => { const removeSelf = () => {
if (triggerWords.length == 1) {
return;
}
triggerWords = triggerWords.slice(0, index).concat(triggerWords.slice(index + 1)); triggerWords = triggerWords.slice(0, index).concat(triggerWords.slice(index + 1));
forceUpdate(); forceUpdate();
}; };
@ -117,7 +120,7 @@ const settings = definePluginSettings({
export default definePlugin({ export default definePlugin({
name: "ContentWarning", name: "ContentWarning",
authors: [Devs.camila314], authors: [Devs.camila314],
description: "Allows you to specify certain trigger words that will be blurred by default. Clicking on the blurred content will reveal it.", description: "Allows you to specify certain trigger words",
settings, settings,
patches: [ patches: [
{ {
@ -130,6 +133,7 @@ export default definePlugin({
], ],
beforeSave() { beforeSave() {
console.log(triggerWords);
DataStore.set(WORDS_KEY, triggerWords); DataStore.set(WORDS_KEY, triggerWords);
return true; return true;
}, },
@ -144,5 +148,6 @@ export default definePlugin({
async start() { async start() {
triggerWords = await DataStore.get(WORDS_KEY) ?? [""]; triggerWords = await DataStore.get(WORDS_KEY) ?? [""];
console.log(triggerWords);
} }
}); });