From 7de0a0ae65b1384553b51a1e0d744823b9adf026 Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Thu, 30 Jul 2020 16:49:11 +0200 Subject: [PATCH] Add Subscreen for blocked Users --- .../session/LeftPaneSettingSection.tsx | 5 +++ .../session/settings/SessionSettings.tsx | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/ts/components/session/LeftPaneSettingSection.tsx b/ts/components/session/LeftPaneSettingSection.tsx index 7d729e498..1cfde2986 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('settingsUnblockHeader'), + hidden: isSecondaryDevice, + }, { id: SessionSettingCategory.Permissions, title: window.i18n('permissionSettingsTitle'), diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 3b4076da0..ed2ece37b 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -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 @@ -589,6 +592,44 @@ export class SettingsView extends React.Component { ]; } + private getBlockedUserSettings(): Array { + const results: Array = []; + const model = window.getConversations(); + + for (const currentModel of model.models) { + let displayName = currentModel.id; + + if (currentModel.attributes.profile && currentModel.attributes.profile.displayName) { + displayName = currentModel.attributes.profile.displayName + } + + if(currentModel.isBlocked()) { + results.push({ + id: currentModel.id, + title: displayName, + description: currentModel.id, + type: SessionSettingType.Button, + category: SessionSettingCategory.Blocked, + content: { + buttonColor: SessionButtonColor.Danger, + buttonText: window.i18n('unblockUser'), + }, + comparisonValue: undefined, + setFn: () => { + currentModel.unblock() + }, + hidden: false, + onClick: undefined, + confirmationDialogParams: undefined, + }); + } + } + + console.log(results); + + return results; + } + private getLinkedDeviceSettings(): Array { const { linkedPubKeys } = this.state; const { isSecondaryDevice } = this.props;