Skip to content

Commit

Permalink
Merge pull request #547 from glific/session-expiry
Browse files Browse the repository at this point in the history
Session expiry
  • Loading branch information
rathorevaibhav authored Sep 30, 2020
2 parents 7f736f0 + 27d9457 commit e7e7be2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/UI/Timer/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styles from './Timer.module.css';
export interface TimerProps {
time: any;
contactStatus?: string;
contactProviderStatus?: string;
}

export const Timer: React.FC<TimerProps> = (props: TimerProps) => {
Expand Down Expand Up @@ -36,7 +37,10 @@ export const Timer: React.FC<TimerProps> = (props: TimerProps) => {
hours = '0' + hours.toString();
}

if (props.contactStatus && props.contactStatus === 'INVALID') {
if (
(props.contactStatus && props.contactStatus === 'INVALID') ||
props.contactProviderStatus === 'NONE'
) {
return <ContactOptOutIcon />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ChatConversationProps {
contactId: number;
contactName: string;
contactStatus: string;
contactProviderStatus: string;
selected: boolean;
senderLastMessage: any;
onClick: (i: any) => void;
Expand Down Expand Up @@ -106,7 +107,11 @@ const ChatConversation: React.SFC<ChatConversationProps> = (props) => {
<div>
<div className={chatBubble.join(' ')} />
<div className={styles.Timer}>
<Timer time={props.senderLastMessage} contactStatus={props.contactStatus} />
<Timer
time={props.senderLastMessage}
contactStatus={props.contactStatus}
contactProviderStatus={props.contactProviderStatus}
/>
</div>
</div>
<div className={chatInfoClass.join(' ')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const ConversationList: React.SFC<ConversationListProps> = (props) => {
lastMessage={lastMessage}
senderLastMessage={conversation.contact.lastMessageAt}
contactStatus={conversation.contact.status}
contactProviderStatus={conversation.contact.providerStatus}
/>
);
});
Expand Down
5 changes: 4 additions & 1 deletion src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export const ChatInput: React.SFC<ChatInputProps> = (props) => {
}
}

if (props.contactStatus && props.contactStatus === 'INVALID') {
if (
(props.contactStatus && props.contactStatus === 'INVALID') ||
props.contactProviderStatus === 'NONE'
) {
return (
<div className={styles.ContactOptOutMessage}>
Sorry, chat is unavailable with this contact at this moment because they aren’t opted in to
Expand Down
7 changes: 5 additions & 2 deletions src/containers/Chat/ChatMessages/ContactBar/ContactBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ export const ContactBar: React.SFC<ContactBarProps> = (props) => {
<div className={styles.Container}>
<div className={styles.SessionTimer} data-testid="sessionTimer">
<span>Session Timer</span>
<Timer time={props.lastMessageTime} contactStatus={props.contactStatus} />
<Timer
time={props.lastMessageTime}
contactStatus={props.contactStatus}
contactProviderStatus={props.contactProviderStatus}
/>
</div>
<div>
{assignedToGroup ? (
Expand All @@ -328,7 +332,6 @@ export const ContactBar: React.SFC<ContactBarProps> = (props) => {
<Typography className={styles.Title} variant="h6" noWrap data-testid="beneficiaryName">
{props.contactName}
</Typography>

<ClickAwayListener onClickAway={() => setAnchorEl(null)}>
<div className={styles.Configure}>
<DropdownIcon onClick={handleConfigureIconClick} />
Expand Down

0 comments on commit e7e7be2

Please sign in to comment.