From 256b4943cd9720ebf50739347954c9790db0de14 Mon Sep 17 00:00:00 2001 From: Damien Erambert Date: Mon, 4 Apr 2022 21:07:07 +0200 Subject: [PATCH] Add setting to hide pronouns on own accounts --- src/_locales/en/messages.json | 3 +++ src/components/settings/settingsTweetContent.tsx | 6 ++++++ src/features/pronounsDisplay.ts | 9 +++++++++ src/types/btdSettingsTypes.ts | 1 + 4 files changed, 19 insertions(+) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 74755caf8..ba1d52f8a 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -523,5 +523,8 @@ }, "settings_dismiss_banner_paragraph": { "message": "In some cases, the banner that shows up after a Better TweetDeck update can have trouble dismissing itself. Click the button below to fix it." + }, + "settings_dont_show_pronouns_for_your_own_accounts": { + "message": "Don't show pronouns for your own accounts" } } diff --git a/src/components/settings/settingsTweetContent.tsx b/src/components/settings/settingsTweetContent.tsx index cf5b9c106..212a96447 100644 --- a/src/components/settings/settingsTweetContent.tsx +++ b/src/components/settings/settingsTweetContent.tsx @@ -205,6 +205,12 @@ export const SettingsTweetContent: FC = (props) => { ); }, }, + { + initialValue: settings.dontShowPronounsOnOwnAccounts, + introducedIn: '4.8.6', + key: 'dontShowPronounsOnOwnAccounts', + label: , + }, ]}> diff --git a/src/features/pronounsDisplay.ts b/src/features/pronounsDisplay.ts index bd5c8d994..28c8f5bc0 100644 --- a/src/features/pronounsDisplay.ts +++ b/src/features/pronounsDisplay.ts @@ -172,6 +172,15 @@ export const displayPronouns = makeBTDModule(({TD, settings}) => { } TD.services.TwitterUser.prototype.getPronouns = function getPronouns(): string | undefined { + const personalAccountIds = settings.dontShowPronounsOnOwnAccounts + ? TD.controller.clients + .getClientsByService('twitter') + .map((c) => c.oauth.account.state.userId) + : []; + + if (personalAccountIds.includes(this.id)) { + return undefined; + } const cleanBio = removeUrlsFromBio(this.description, this.entities.description); const maybePronouns = extractPronouns(cleanBio) || extractPronouns(this.location) || extractPronouns(this.name); diff --git a/src/types/btdSettingsTypes.ts b/src/types/btdSettingsTypes.ts index 7b6198546..8b187fb4b 100644 --- a/src/types/btdSettingsTypes.ts +++ b/src/types/btdSettingsTypes.ts @@ -98,6 +98,7 @@ export const RBetterTweetDeckSettings = t.type({ showProfileLabels: withDefault(t.boolean, false), extractAndShowPronouns: withDefault(t.boolean, false), + dontShowPronounsOnOwnAccounts: withDefault(t.boolean, false), /** Disable the `tweet` button if images don't have an alt text. */ disableTweetButtonIfAltIsMissing: withDefault(t.boolean, false),