Added online indicator to conversation header.

pull/171/head
Mikunj 6 years ago
parent 8462864373
commit ddfc99a461

@ -162,6 +162,10 @@
this.set({ isOnline: lokiP2pAPI.isOnline(this.id) }); this.set({ isOnline: lokiP2pAPI.isOnline(this.id) });
}, },
isOnline() {
return this.isMe() || this.get('isOnline');
},
isMe() { isMe() {
return this.id === this.ourNumber; return this.id === this.ourNumber;
}, },
@ -391,7 +395,7 @@
status: this.lastMessageStatus, status: this.lastMessageStatus,
text: this.lastMessage, text: this.lastMessage,
}, },
isOnline: this.get('isOnline'), isOnline: this.isOnline(),
onClick: () => this.trigger('select', this), onClick: () => this.trigger('select', this),
}; };

@ -185,6 +185,7 @@
isMe: this.model.isMe(), isMe: this.model.isMe(),
isBlocked: this.model.isBlocked(), isBlocked: this.model.isBlocked(),
isGroup: !this.model.isPrivate(), isGroup: !this.model.isPrivate(),
isOnline: this.model.isOnline(),
expirationSettingName, expirationSettingName,
showBackButton: Boolean(this.panels && this.panels.length), showBackButton: Boolean(this.panels && this.panels.length),
timerOptions: Whisper.ExpirationTimerOptions.map(item => ({ timerOptions: Whisper.ExpirationTimerOptions.map(item => ({

@ -14,6 +14,7 @@ interface Props {
profileName?: string; profileName?: string;
size: number; size: number;
borderColor?: string; borderColor?: string;
borderWidth?: number;
} }
interface State { interface State {
@ -49,6 +50,7 @@ export class Avatar extends React.Component<Props, State> {
phoneNumber, phoneNumber,
profileName, profileName,
borderColor, borderColor,
borderWidth,
} = this.props; } = this.props;
const { imageBroken } = this.state; const { imageBroken } = this.state;
const hasImage = avatarPath && !imageBroken; const hasImage = avatarPath && !imageBroken;
@ -61,12 +63,7 @@ export class Avatar extends React.Component<Props, State> {
!name && profileName ? ` ~${profileName}` : '' !name && profileName ? ` ~${profileName}` : ''
}`; }`;
const borderStyle = borderColor const borderStyle = this.getBorderStyle(borderColor, borderWidth);
? {
borderColor: borderColor,
borderStyle: 'solid',
}
: undefined;
return ( return (
<img <img
@ -79,17 +76,18 @@ export class Avatar extends React.Component<Props, State> {
} }
public renderNoImage() { public renderNoImage() {
const { conversationType, name, size, borderColor } = this.props; const {
conversationType,
name,
size,
borderColor,
borderWidth,
} = this.props;
const initials = getInitials(name); const initials = getInitials(name);
const isGroup = conversationType === 'group'; const isGroup = conversationType === 'group';
const borderStyle = borderColor const borderStyle = this.getBorderStyle(borderColor, borderWidth);
? {
borderColor: borderColor,
borderStyle: 'solid',
}
: undefined;
if (!isGroup && initials) { if (!isGroup && initials) {
return ( return (
@ -140,4 +138,16 @@ export class Avatar extends React.Component<Props, State> {
</div> </div>
); );
} }
private getBorderStyle(color?: string, width?: number) {
const borderWidth = typeof width === 'number' ? width : 3;
return color
? {
borderColor: color,
borderStyle: 'solid',
borderWidth: borderWidth,
}
: undefined;
}
} }

@ -7,7 +7,7 @@ import { Timestamp } from './conversation/Timestamp';
import { ContactName } from './conversation/ContactName'; import { ContactName } from './conversation/ContactName';
import { TypingAnimation } from './conversation/TypingAnimation'; import { TypingAnimation } from './conversation/TypingAnimation';
import { Localizer } from '../types/Util'; import { Colors, Localizer } from '../types/Util';
interface Props { interface Props {
phoneNumber: string; phoneNumber: string;
@ -47,6 +47,8 @@ export class ConversationListItem extends React.Component<Props> {
isOnline, isOnline,
} = this.props; } = this.props;
const borderColor = isOnline ? Colors.ONLINE : Colors.OFFLINE;
return ( return (
<div className="module-conversation-list-item__avatar-container"> <div className="module-conversation-list-item__avatar-container">
<Avatar <Avatar
@ -58,7 +60,7 @@ export class ConversationListItem extends React.Component<Props> {
phoneNumber={phoneNumber} phoneNumber={phoneNumber}
profileName={profileName} profileName={profileName}
size={48} size={48}
borderColor={isOnline ? '#1c8260' : '#3d3e44'} borderColor={borderColor}
/> />
{this.renderUnread()} {this.renderUnread()}
</div> </div>

@ -2,7 +2,7 @@ import React from 'react';
import { ContactName } from './ContactName'; import { ContactName } from './ContactName';
import { Avatar } from '../Avatar'; import { Avatar } from '../Avatar';
import { Localizer } from '../../types/Util'; import { Colors, Localizer } from '../../types/Util';
import { import {
ContextMenu, ContextMenu,
ContextMenuTrigger, ContextMenuTrigger,
@ -33,6 +33,7 @@ interface Props {
isBlocked: boolean; isBlocked: boolean;
isMe: boolean; isMe: boolean;
isGroup: boolean; isGroup: boolean;
isOnline?: boolean;
expirationSettingName?: string; expirationSettingName?: string;
showBackButton: boolean; showBackButton: boolean;
timerOptions: Array<TimerOption>; timerOptions: Array<TimerOption>;
@ -118,8 +119,11 @@ export class ConversationHeader extends React.Component<Props> {
name, name,
phoneNumber, phoneNumber,
profileName, profileName,
isOnline,
} = this.props; } = this.props;
const borderColor = isOnline ? Colors.ONLINE : Colors.OFFLINE_LIGHT;
return ( return (
<span className="module-conversation-header__avatar"> <span className="module-conversation-header__avatar">
<Avatar <Avatar
@ -131,6 +135,8 @@ export class ConversationHeader extends React.Component<Props> {
phoneNumber={phoneNumber} phoneNumber={phoneNumber}
profileName={profileName} profileName={profileName}
size={28} size={28}
borderColor={borderColor}
borderWidth={2}
/> />
</span> </span>
); );

@ -18,3 +18,9 @@ export type Color =
| 'purple' | 'purple'
| 'red' | 'red'
| 'teal'; | 'teal';
export enum Colors {
OFFLINE = '#3d3e44',
OFFLINE_LIGHT = '#cccece',
ONLINE = '#1c8260',
}

Loading…
Cancel
Save