From 0153c83afba2dd29f234dba8ad942f7cccc39e9d Mon Sep 17 00:00:00 2001 From: Bauke Date: Tue, 15 Aug 2023 12:15:16 +0200 Subject: [PATCH] Narrow the ReplacementType value before saving. --- source/options/components/anonymize-usernames.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/options/components/anonymize-usernames.tsx b/source/options/components/anonymize-usernames.tsx index 39779d9..bfd9f89 100644 --- a/source/options/components/anonymize-usernames.tsx +++ b/source/options/components/anonymize-usernames.tsx @@ -1,5 +1,10 @@ import {Component} from "preact"; -import {fromStorage, Feature, ReplacementType} from "../../storage/exports.js"; +import { + fromStorage, + isReplacementType, + Feature, + ReplacementType, +} from "../../storage/exports.js"; import {Setting, type SettingProps} from "./index.js"; type State = { @@ -23,7 +28,7 @@ export class AnonymizeUsernamesSetting extends Component { replacementTypeChanged = async (event: Event) => { const newValue = (event.target as HTMLInputElement)!.value; const {data} = this.state; - if (data === undefined) { + if (data === undefined || !isReplacementType(newValue)) { return; }