From 9bd35ee17e7e746be4b2d76f92ef5fe596a1f4a2 Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 16 Aug 2023 15:45:27 +0200 Subject: [PATCH] Add storage and UI for anonymizing only the logged in user. --- .../components/anonymize-usernames.tsx | 23 +++++++++++++++++++ source/storage/anonymize-usernames.ts | 1 + source/storage/exports.ts | 1 + 3 files changed, 25 insertions(+) diff --git a/source/options/components/anonymize-usernames.tsx b/source/options/components/anonymize-usernames.tsx index bfd9f89..9868150 100644 --- a/source/options/components/anonymize-usernames.tsx +++ b/source/options/components/anonymize-usernames.tsx @@ -37,6 +37,17 @@ export class AnonymizeUsernamesSetting extends Component { this.setState({data}); }; + selfOnlyClicked = async () => { + const {data} = this.state; + if (data === undefined) { + return; + } + + data.value.selfOnly = !data.value.selfOnly; + await data.save(); + this.setState({data}); + }; + render() { const {data} = this.state; if (data === undefined) { @@ -52,6 +63,17 @@ export class AnonymizeUsernamesSetting extends Component { )); + const selfOnlyCheckbox = ( + + ); + return (

@@ -67,6 +89,7 @@ export class AnonymizeUsernamesSetting extends Component { {replacementTypeOptions} +

  • {selfOnlyCheckbox}
  • ); diff --git a/source/storage/anonymize-usernames.ts b/source/storage/anonymize-usernames.ts index 7653a78..1482e69 100644 --- a/source/storage/anonymize-usernames.ts +++ b/source/storage/anonymize-usernames.ts @@ -20,4 +20,5 @@ export function isReplacementType(input: string): input is ReplacementType { */ export type AnonymizeUsernamesData = { replacementType: ReplacementType; + selfOnly: boolean; }; diff --git a/source/storage/exports.ts b/source/storage/exports.ts index e54db1b..ff3eefb 100644 --- a/source/storage/exports.ts +++ b/source/storage/exports.ts @@ -84,6 +84,7 @@ export const storageValues = { key: Feature.AnonymizeUsernames, value: { replacementType: ReplacementType.Numerical, + selfOnly: false, }, storage: browser.storage.sync, }),