Updated UI in conversation to support user blocking behaviour.

pull/47/head
Mikunj 7 years ago
parent 8cc9b7b54b
commit ae2e2fa2ae

@ -1619,5 +1619,11 @@
"example": "Bob" "example": "Bob"
} }
} }
},
"blockUser": {
"message": "Block user"
},
"unblockUser": {
"message": "Unblock user"
} }
} }

@ -86,7 +86,7 @@
return m.get('number'); return m.get('number');
}, },
getNumber(number) { getNumber(number) {
return this.model.find(m => m.number === number); return this.models.find(m => m.number === number);
}, },
}); });

@ -1,6 +1,6 @@
/* global _: false */ /* global _: false */
/* global Backbone: false */ /* global Backbone: false */
/* global libphonenumber: false */ /* global BlockedNumberController: false */
/* global ConversationController: false */ /* global ConversationController: false */
/* global libsignal: false */ /* global libsignal: false */
@ -147,7 +147,17 @@
isMe() { isMe() {
return this.id === this.ourNumber; return this.id === this.ourNumber;
}, },
isBlocked() {
return BlockedNumberController.isBlocked(this.id);
},
block() {
BlockedNumberController.block(this.id);
this.trigger('change');
},
unblock() {
BlockedNumberController.unblock(this.id);
this.trigger('change');
},
async cleanup() { async cleanup() {
await window.Signal.Types.Conversation.deleteExternalFiles( await window.Signal.Types.Conversation.deleteExternalFiles(
this.attributes, this.attributes,
@ -280,6 +290,7 @@
unreadCount: this.get('unreadCount') || 0, unreadCount: this.get('unreadCount') || 0,
isSelected: this.isSelected, isSelected: this.isSelected,
showFriendRequestIndicator: this.pendingFriendRequest, showFriendRequestIndicator: this.pendingFriendRequest,
isBlocked: this.isBlocked(),
lastMessage: { lastMessage: {
status: this.lastMessageStatus, status: this.lastMessageStatus,
text: this.lastMessage, text: this.lastMessage,

@ -7,6 +7,7 @@
/* global Signal: false */ /* global Signal: false */
/* global storage: false */ /* global storage: false */
/* global Whisper: false */ /* global Whisper: false */
/* global BlockNumberConversation: false */
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
(function() { (function() {
@ -170,6 +171,7 @@
isVerified: this.model.isVerified(), isVerified: this.model.isVerified(),
isKeysPending: this.model.isKeyExchangeCompleted() === false, isKeysPending: this.model.isKeyExchangeCompleted() === false,
isMe: this.model.isMe(), isMe: this.model.isMe(),
isBlocked: this.model.isBlocked(),
isGroup: !this.model.isPrivate(), isGroup: !this.model.isPrivate(),
expirationSettingName, expirationSettingName,
showBackButton: Boolean(this.panels && this.panels.length), showBackButton: Boolean(this.panels && this.panels.length),
@ -200,6 +202,13 @@
this.resetPanel(); this.resetPanel();
this.updateHeader(); this.updateHeader();
}, },
onBlockUser: () => {
this.model.block();
},
onUnblockUser: () => {
this.model.unblock();
},
}; };
}; };
this.titleView = new Whisper.ReactWrapperView({ this.titleView = new Whisper.ReactWrapperView({

@ -1831,6 +1831,11 @@
border-left: 4px solid $color-conversation-indigo; border-left: 4px solid $color-conversation-indigo;
} }
.module-conversation-list-item--is-blocked {
padding-left: 12px;
border-left: 4px solid $color-conversation-red;
}
.module-conversation-list-item--is-selected { .module-conversation-list-item--is-selected {
background-color: $color-gray-05; background-color: $color-gray-05;
} }

@ -1269,6 +1269,10 @@ body.dark-theme {
border-left: 4px solid $color-conversation-indigo; border-left: 4px solid $color-conversation-indigo;
} }
.module-conversation-list-item--is-blocked {
border-left: 4px solid $color-conversation-red;
}
.module-conversation-list-item--is-selected { .module-conversation-list-item--is-selected {
background-color: $color-dark-70; background-color: $color-dark-70;
} }

@ -24,6 +24,7 @@ interface Props {
text: string; text: string;
}; };
showFriendRequestIndicator?: boolean; showFriendRequestIndicator?: boolean;
isBlocked: boolean;
i18n: Localizer; i18n: Localizer;
onClick?: () => void; onClick?: () => void;
@ -157,7 +158,7 @@ export class ConversationListItem extends React.Component<Props> {
} }
public render() { public render() {
const { unreadCount, onClick, isSelected, showFriendRequestIndicator } = this.props; const { unreadCount, onClick, isSelected, showFriendRequestIndicator, isBlocked } = this.props;
return ( return (
<div <div
@ -167,7 +168,8 @@ export class ConversationListItem extends React.Component<Props> {
'module-conversation-list-item', 'module-conversation-list-item',
unreadCount > 0 ? 'module-conversation-list-item--has-unread' : null, unreadCount > 0 ? 'module-conversation-list-item--has-unread' : null,
isSelected ? 'module-conversation-list-item--is-selected' : null, isSelected ? 'module-conversation-list-item--is-selected' : null,
showFriendRequestIndicator ? 'module-conversation-list-item--has-friend-request' : null showFriendRequestIndicator ? 'module-conversation-list-item--has-friend-request' : null,
isBlocked ? 'module-conversation-list-item--is-blocked' : null,
)} )}
> >
{this.renderAvatar()} {this.renderAvatar()}

@ -30,6 +30,7 @@ interface Props {
color: string; color: string;
avatarPath?: string; avatarPath?: string;
isBlocked: boolean;
isMe: boolean; isMe: boolean;
isGroup: boolean; isGroup: boolean;
expirationSettingName?: string; expirationSettingName?: string;
@ -44,6 +45,9 @@ interface Props {
onShowAllMedia: () => void; onShowAllMedia: () => void;
onShowGroupMembers: () => void; onShowGroupMembers: () => void;
onGoBack: () => void; onGoBack: () => void;
onBlockUser: () => void;
onUnblockUser: () => void;
} }
export class ConversationHeader extends React.Component<Props> { export class ConversationHeader extends React.Component<Props> {
@ -182,6 +186,7 @@ export class ConversationHeader extends React.Component<Props> {
public renderMenu(triggerId: string) { public renderMenu(triggerId: string) {
const { const {
i18n, i18n,
isBlocked,
isMe, isMe,
isGroup, isGroup,
onDeleteMessages, onDeleteMessages,
@ -191,10 +196,15 @@ export class ConversationHeader extends React.Component<Props> {
onShowGroupMembers, onShowGroupMembers,
onShowSafetyNumber, onShowSafetyNumber,
timerOptions, timerOptions,
onBlockUser,
onUnblockUser,
} = this.props; } = this.props;
const disappearingTitle = i18n('disappearingMessages') as any; const disappearingTitle = i18n('disappearingMessages') as any;
const blockTitle = isBlocked ? i18n('unblockUser') : i18n('blockUser');
const blockHandler = isBlocked ? onUnblockUser : onBlockUser;
return ( return (
<ContextMenu id={triggerId}> <ContextMenu id={triggerId}>
<SubMenu title={disappearingTitle}> <SubMenu title={disappearingTitle}>
@ -223,6 +233,10 @@ export class ConversationHeader extends React.Component<Props> {
{!isGroup ? ( {!isGroup ? (
<MenuItem onClick={onResetSession}>{i18n('resetSession')}</MenuItem> <MenuItem onClick={onResetSession}>{i18n('resetSession')}</MenuItem>
) : null} ) : null}
{/* Only show the block on other conversations */}
{!isMe ? (
<MenuItem onClick={blockHandler}>{blockTitle}</MenuItem>
) : null}
<MenuItem onClick={onDeleteMessages}>{i18n('deleteMessages')}</MenuItem> <MenuItem onClick={onDeleteMessages}>{i18n('deleteMessages')}</MenuItem>
</ContextMenu> </ContextMenu>
); );

Loading…
Cancel
Save