From 8d544a9d875f9a9f9f845f771295939d8d7d7a34 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 14 Jul 2020 15:56:40 +1000 Subject: [PATCH] make redux store update on block/unblock --- js/models/conversations.js | 4 ++-- ts/components/ConversationListItem.tsx | 5 ++--- ts/state/ducks/conversations.ts | 1 + ts/state/selectors/conversations.ts | 11 +++++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 25fac7d90..e75044b0e 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -250,7 +250,7 @@ ? BlockedNumberController.block(this.id) : BlockedNumberController.blockGroup(this.id); await promise; - this.trigger('change'); + this.trigger('change', this); this.messageCollection.forEach(m => m.trigger('change')); this.updateTextInputState(); }, @@ -262,7 +262,7 @@ ? BlockedNumberController.unblock(this.id) : BlockedNumberController.unblockGroup(this.id); await promise; - this.trigger('change'); + this.trigger('change', this); this.messageCollection.forEach(m => m.trigger('change')); this.updateTextInputState(); }, diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index 6abcbe9d0..72254409c 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -11,7 +11,6 @@ import { ContactName } from './conversation/ContactName'; import { TypingAnimation } from './conversation/TypingAnimation'; import { Colors, LocalizerType } from '../types/Util'; -import { SessionButton, SessionButtonColor } from './session/SessionButton'; export type PropsData = { id: string; @@ -181,11 +180,11 @@ export class ConversationListItem extends React.PureComponent { {!isPublic && !isRss && !isMe ? ( {blockTitle} ) : null} - {!isPublic && !isRss && !isMe ? ( + {/* {!isPublic && !isRss && !isMe ? ( {i18n('changeNickname')} - ) : null} + ) : null} */} {!isPublic && !isRss && !isMe && hasNickname ? ( {i18n('clearNickname')} ) : null} diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 80c2ddc47..ed24d82ee 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -54,6 +54,7 @@ export type ConversationType = { isTyping: boolean; isSecondary?: boolean; primaryDevice: string; + isBlocked: boolean; }; export type ConversationLookupType = { [key: string]: ConversationType; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 786340d27..35f19a9f0 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -11,6 +11,7 @@ import { import { getIntl, getRegionCode, getUserNumber } from './user'; import { PropsData as ConversationListItemPropsType } from '../../components/ConversationListItem'; +import { BlockedNumberController } from '../../util'; export const getConversations = (state: StateType): ConversationsStateType => state.conversations; @@ -119,6 +120,16 @@ export const _getLeftPaneLists = ( isSelected: true, }; } + const isBlocked = + BlockedNumberController.isBlocked(conversation.primaryDevice) || + BlockedNumberController.isGroupBlocked(conversation.id); + + if (isBlocked) { + conversation = { + ...conversation, + isBlocked: true, + }; + } // Add Open Group to list as soon as the name has been set if (