add the accept/decline buttons on friend requests in conversationslist

pull/712/head
Audric Ackermann 5 years ago
parent fc938df520
commit c9000c3f26

@ -2427,5 +2427,11 @@
}, },
"yourPublicKey": { "yourPublicKey": {
"message": "Your Public Key" "message": "Your Public Key"
},
"accept": {
"message": "Accept"
},
"decline": {
"message": "Decline"
} }
} }

@ -284,6 +284,28 @@ $session-compose-margin: 20px;
&-content { &-content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.module-conversation-list-item {
&--has-friend-request {
border: 1px solid $session-shade-8 !important;
.module-conversation__user__profile-number,
.module-conversation__user__profile-name {
font-size: 13px !important;
}
}
&__buttons {
display: flex;
.session-button {
font-size: 11px;
padding: 6px;
height: auto;
margin: 0px;
line-height: 14px;
}
}
}
} }
&-bottom-buttons { &-bottom-buttons {
@ -298,6 +320,8 @@ $session-compose-margin: 20px;
line-height: 50px; line-height: 50px;
} }
} }
} }
.panel-text-divider { .panel-text-divider {

@ -11,6 +11,7 @@ import { ContactName } from './conversation/ContactName';
import { TypingAnimation } from './conversation/TypingAnimation'; import { TypingAnimation } from './conversation/TypingAnimation';
import { Colors, LocalizerType } from '../types/Util'; import { Colors, LocalizerType } from '../types/Util';
import { SessionButton, SessionButtonColor } from './session/SessionButton';
export type PropsData = { export type PropsData = {
id: string; id: string;
@ -72,9 +73,15 @@ export class ConversationListItem extends React.PureComponent<Props> {
phoneNumber, phoneNumber,
profileName, profileName,
isOnline, isOnline,
showFriendRequestIndicator,
} = this.props; } = this.props;
const borderColor = isOnline ? Colors.ONLINE : Colors.OFFLINE;
let borderColor = undefined;
if (!showFriendRequestIndicator) {
borderColor = isOnline ? Colors.ONLINE : Colors.OFFLINE;
}
const iconSize = showFriendRequestIndicator ? 28 : 48;
return ( return (
<div className="module-conversation-list-item__avatar-container"> <div className="module-conversation-list-item__avatar-container">
@ -87,7 +94,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
name={name} name={name}
phoneNumber={phoneNumber} phoneNumber={phoneNumber}
profileName={profileName} profileName={profileName}
size={48} size={iconSize}
borderColor={borderColor} borderColor={borderColor}
/> />
</div> </div>
@ -114,7 +121,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
} }
public renderHeader() { public renderHeader() {
const { unreadCount, i18n, isMe, lastUpdated, isFriendItem } = this.props; const { unreadCount, i18n, isMe, lastUpdated, isFriendItem, showFriendRequestIndicator } = this.props;
return ( return (
<div className="module-conversation-list-item__header"> <div className="module-conversation-list-item__header">
@ -128,7 +135,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
> >
{isMe ? i18n('noteToSelf') : this.renderUser()} {isMe ? i18n('noteToSelf') : this.renderUser()}
</div> </div>
{this.renderUnread()} {showFriendRequestIndicator || this.renderUnread()}
{!isFriendItem && ( {!isFriendItem && (
<div <div
className={classNames( className={classNames(
@ -138,12 +145,13 @@ export class ConversationListItem extends React.PureComponent<Props> {
: null : null
)} )}
> >
<Timestamp {showFriendRequestIndicator || (<Timestamp
timestamp={lastUpdated} timestamp={lastUpdated}
extended={false} extended={false}
module="module-conversation-list-item__header__timestamp" module="module-conversation-list-item__header__timestamp"
i18n={i18n} i18n={i18n}
/> />)
}
</div> </div>
)} )}
</div> </div>
@ -209,6 +217,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
unreadCount, unreadCount,
i18n, i18n,
isFriendItem, isFriendItem,
showFriendRequestIndicator,
} = this.props; } = this.props;
if (isFriendItem) { if (isFriendItem) {
@ -226,6 +235,10 @@ export class ConversationListItem extends React.PureComponent<Props> {
text = text.replace(/<[^>]*>?/gm, ''); text = text.replace(/<[^>]*>?/gm, '');
} }
if (showFriendRequestIndicator) {
text = text.replace('Friend Request: ', '');
}
if (isEmpty(text)) { if (isEmpty(text)) {
return null; return null;
} }
@ -265,6 +278,16 @@ export class ConversationListItem extends React.PureComponent<Props> {
); );
} }
public renderFriendRequestButtons() {
return (
<div className="module-conversation-list-item__buttons">
<SessionButton text={window.i18n('decline')} buttonColor={SessionButtonColor.None}/>
<SessionButton text={window.i18n('accept')} />
</div>
);
}
public render() { public render() {
const { const {
phoneNumber, phoneNumber,
@ -278,6 +301,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
mentionedUs, mentionedUs,
} = this.props; } = this.props;
const triggerId = `${phoneNumber}-ctxmenu-${Date.now()}`; const triggerId = `${phoneNumber}-ctxmenu-${Date.now()}`;
return ( return (
@ -311,6 +335,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
{this.renderHeader()} {this.renderHeader()}
{this.renderMessage()} {this.renderMessage()}
</div> </div>
{showFriendRequestIndicator && this.renderFriendRequestButtons()}
</div> </div>
</ContextMenuTrigger> </ContextMenuTrigger>
<Portal>{this.renderContextMenu(triggerId)}</Portal> <Portal>{this.renderContextMenu(triggerId)}</Portal>

@ -19,6 +19,7 @@ export enum SessionButtonColor {
Success = 'success', Success = 'success',
Danger = 'danger', Danger = 'danger',
Warning = 'warning', Warning = 'warning',
None = '',
} }
interface Props { interface Props {

@ -24,5 +24,5 @@ export type ColorType =
export enum Colors { export enum Colors {
OFFLINE = '#3d3e44', OFFLINE = '#3d3e44',
OFFLINE_LIGHT = '#cccece', OFFLINE_LIGHT = '#cccece',
ONLINE = '#1c8260', ONLINE = '#00f782',
} }

Loading…
Cancel
Save