diff --git a/app/components/HistoryCard.js b/app/components/HistoryCard.js
index 669ad24..b8af4cc 100644
--- a/app/components/HistoryCard.js
+++ b/app/components/HistoryCard.js
@@ -1,159 +1,164 @@
import React from 'react';
import { View } from 'react-native';
import PropTypes from 'prop-types';
import moment from 'moment';
import momentFormat from 'moment-duration-format';
import { Card, IconButton, Caption, Title, Subheading } from 'react-native-paper';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import styles from '../assets/styles/blink/_HistoryCard.scss';
import UserIcon from './UserIcon';
const HistoryCard = (props) => {
const identity = {
displayName: props.historyItem.displayName || props.historyItem.name,
uri: props.historyItem.remoteParty || props.historyItem.uri,
type: props.historyItem.type || 'contact',
photo: props.historyItem.photo,
label: props.historyItem.label
}
//console.log('History card', props.historyItem);
const startVideoCall = (e) => {
e.stopPropagation();
props.setTargetUri(identity.uri);
// We need to wait for targetURI
setImmediate(() => {
props.startVideoCall(e);
});
}
const startAudioCall = (e) => {
e.stopPropagation();
props.setTargetUri(identity.uri);
// We need to wait for targetURI
setImmediate(() => {
props.startAudioCall(e);
});
}
let containerClass = styles.portraitContainer;
if (props.isTablet) {
containerClass = (props.orientation === 'landscape') ? styles.landscapeTabletContainer : styles.portraitTabletContainer;
} else {
containerClass = (props.orientation === 'landscape') ? styles.landscapeContainer : styles.portraitContainer;
}
let color = {};
const name = identity.displayName || identity.uri;
let title = identity.displayName || identity.uri;
let subtitle = identity.uri;
if (props.historyItem.conference) {
// console.log('Item participants', props.historyItem.participants);
if (props.historyItem.participants) {
if (props.historyItem.participants.length === 0) {
subtitle = 'No participants';
} else if (props.historyItem.participants.length === 1) {
subtitle = 'One participant';
} else {
subtitle = props.historyItem.participants.length + ' participants';
}
}
}
+ let description = props.historyItem.startTime;
+
if (identity.type === 'history') {
let duration = moment.duration(props.historyItem.duration, 'seconds').format('hh:mm:ss', {trim: false});
+
if (props.historyItem.direction === 'received' && props.historyItem.duration === 0) {
color.color = '#a94442';
duration = 'missed';
} else if (props.historyItem.direction === 'placed' && props.historyItem.duration === 0) {
- // color.color = 'blue';
duration = 'cancelled';
}
if (duration) {
let subtitle = identity.uri + ' (' + duration + ')';
}
if (!identity.displayName) {
title = identity.uri;
if (duration === 'missed') {
subtitle = 'Last call missed';
} else if (duration === 'cancelled') {
subtitle = 'Last call cancelled';
} else {
subtitle = 'Last call duration ' + duration ;
}
}
+
+ description = description + ' (' + duration + ')';
+
return (
{props.setTargetUri(identity.uri)}}
onLongPress={startVideoCall}
style={containerClass}
>
{title}
{subtitle}
- {props.historyItem.startTime}
+ {description}
);
} else {
if (identity.label) {
subtitle = identity.uri + ' (' + identity.label + ')';
}
return (
{props.setTargetUri(identity.uri, props.historyItem)}}
onLongPress={startVideoCall}
style={containerClass}
>
{title}
{subtitle}
);
}
/*
*/
}
HistoryCard.propTypes = {
historyItem : PropTypes.object,
startAudioCall : PropTypes.func,
startVideoCall : PropTypes.func,
setTargetUri : PropTypes.func,
orientation : PropTypes.string,
isTablet : PropTypes.bool
};
export default HistoryCard;