Merge pull request #1297 from konstantinullrich/feature/blocked-list-in-settings

pull/1308/head
Audric Ackermann 5 years ago committed by GitHub
commit 08433aa676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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"

@ -212,6 +212,11 @@ export class LeftPaneSettingSection extends React.Component<Props, State> {
title: window.i18n('privacySettingsTitle'),
hidden: false,
},
{
id: SessionSettingCategory.Blocked,
title: window.i18n('blockedSettingsTitle'),
hidden: false,
},
{
id: SessionSettingCategory.Permissions,
title: window.i18n('permissionSettingsTitle'),

@ -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<SettingsViewProps, State> {
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<SettingsViewProps, State> {
];
}
private getBlockedUserSettings(): Array<LocalSettingType> {
const results: Array<LocalSettingType> = [];
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<LocalSettingType> {
const { linkedPubKeys } = this.state;
const { isSecondaryDevice } = this.props;

Loading…
Cancel
Save