diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 83a122f85..108077218 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1563,6 +1563,18 @@ "unblockUser": { "message": "Unblock User" }, + "blockedSettingsTitle": { + "message": "Blocked Users", + "description": "Shown in the settings page as the heading for the blocked user settings" + }, + "editProfileTitle": { + "message": "Change your own display name", + "description": "The title shown when user edits their own profile" + }, + "editProfileDisplayNameWarning": { + "message": "Note: Your display name will be visible to your contacts", + "description": "Shown to the user as a warning about setting display name" + }, "copyPublicKey": { "message": "Copy Public Key", "description": "Button action that the user can click to copy their public keys" diff --git a/ts/components/session/LeftPaneSettingSection.tsx b/ts/components/session/LeftPaneSettingSection.tsx index 77ec15498..a1e4f7645 100644 --- a/ts/components/session/LeftPaneSettingSection.tsx +++ b/ts/components/session/LeftPaneSettingSection.tsx @@ -212,6 +212,11 @@ export class LeftPaneSettingSection extends React.Component { title: window.i18n('privacySettingsTitle'), hidden: false, }, + { + id: SessionSettingCategory.Blocked, + title: window.i18n('blockedSettingsTitle'), + hidden: false, + }, { id: SessionSettingCategory.Permissions, title: window.i18n('permissionSettingsTitle'), diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index c73b0d8ad..cd956000f 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -7,7 +7,7 @@ import { SessionButtonColor, SessionButtonType, } from '../SessionButton'; -import { UserUtil } from '../../../util'; +import { BlockedNumberController, UserUtil } from '../../../util'; import { MultiDeviceProtocol } from '../../../session/protocols'; import { PubKey } from '../../../session/types'; import { NumberUtils } from '../../../session/utils'; @@ -103,6 +103,9 @@ export class SettingsView extends React.Component { if (category === SessionSettingCategory.Devices) { // special case for linked devices settings = this.getLinkedDeviceSettings(); + } else if(category === SessionSettingCategory.Blocked) { + // special case for blocked user + settings = this.getBlockedUserSettings(); } else { // Grab initial values from database on startup // ID corresponds to installGetter parameters in preload.js @@ -592,6 +595,45 @@ export class SettingsView extends React.Component { ]; } + private getBlockedUserSettings(): Array { + const results: Array = []; + const blockedNumbers = BlockedNumberController.getBlockedNumbers(); + + for (const blockedNumber of blockedNumbers) { + + let displayName = `User (...${blockedNumber.substr(-6)})`; + + const currentModel = window.ConversationController.get(blockedNumber); + if ( + currentModel && + currentModel.attributes.profile && + currentModel.attributes.profile.displayName + ) { + displayName = currentModel.attributes.profile.displayName + } + + results.push({ + id: blockedNumber, + title: displayName, + description: blockedNumber, + type: SessionSettingType.Button, + category: SessionSettingCategory.Blocked, + content: { + buttonColor: SessionButtonColor.Danger, + buttonText: window.i18n('unblockUser'), + }, + comparisonValue: undefined, + setFn: async () => { + await BlockedNumberController.unblock(blockedNumber) + }, + hidden: false, + onClick: undefined, + confirmationDialogParams: undefined, + }); + } + return results; + } + private getLinkedDeviceSettings(): Array { const { linkedPubKeys } = this.state; const { isSecondaryDevice } = this.props;