From 4fbbbc26a4dd32a97604bf4ea4da7bd2743e8e68 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 14 Aug 2020 10:56:44 +1000 Subject: [PATCH] make blockled list number updates on unblock --- _locales/en/messages.json | 3 +++ .../session/settings/SessionSettings.tsx | 26 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 108077218..428f97e0c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1563,6 +1563,9 @@ "unblockUser": { "message": "Unblock User" }, + "unblocked": { + "message": "Unblocked" + }, "blockedSettingsTitle": { "message": "Blocked Users", "description": "Shown in the settings page as the heading for the blocked user settings" diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 5c81717be..043dcd6dd 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -600,22 +600,20 @@ export class SettingsView extends React.Component { const blockedNumbers = BlockedNumberController.getBlockedNumbers(); for (const blockedNumber of blockedNumbers) { - - let displayName = `User (...${blockedNumber.substr(-6)})`; + let title: string; const currentModel = window.ConversationController.get(blockedNumber); - if ( - currentModel && - currentModel.attributes.profile && - currentModel.attributes.profile.displayName - ) { - displayName = currentModel.attributes.profile.displayName - } + title = + currentModel.getProfileName() || + currentModel.getName() || + window.i18n('anonymous'); + + title = `${title} ${window.shortenPubkey(blockedNumber)}`; results.push({ id: blockedNumber, - title: displayName, - description: blockedNumber, + title, + description: '', type: SessionSettingType.Button, category: SessionSettingCategory.Blocked, content: { @@ -624,7 +622,11 @@ export class SettingsView extends React.Component { }, comparisonValue: undefined, setFn: async () => { - await BlockedNumberController.unblock(blockedNumber) + await currentModel.unblock(); + ToastUtils.push({ + title: window.i18n('unblocked'), + id: 'unblocked', + }); }, hidden: false, onClick: undefined,