Skip to content

Commit

Permalink
feat: Show request time on logs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrazier committed Jun 28, 2020
1 parent 506cd23 commit d9115fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/ResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress }) => {

const status = request.status > 0 ? request.status : '-';

const pad = (num: number) => `0${num}`.slice(-2);

const getTime = (time: number) => {
const date = new Date(time);
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes());
const seconds = pad(date.getSeconds());

return `${hours}:${minutes}:${seconds}`;
};

return (
<MaybeTouchable
style={[styles.container, style]}
Expand All @@ -60,6 +71,7 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress }) => {
<Text style={styles.text}>
{request.duration > 0 ? `${request.duration}ms` : 'pending'}
</Text>
<Text style={styles.time}>{getTime(request.startTime)}</Text>
</View>
<Text
style={[styles.text, styles.content, getUrlTextColor(request.status)]}
Expand Down Expand Up @@ -112,6 +124,11 @@ const themedStyles = (theme: Theme) =>
padding: 0,
width: 80,
},
time: {
color: theme.colors.muted,
marginTop: 5,
marginHorizontal: 2,
},
});

export default ResultItem;
3 changes: 3 additions & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type Theme = {
statusGood: string;
statusWarning: string;
statusBad: string;
muted: string;
};
};

Expand All @@ -25,6 +26,7 @@ const darkTheme: Theme = {
statusGood: '#28a844',
statusWarning: '#ffc007',
statusBad: '#dd3444',
muted: '#cccccc',
},
};
const lightTheme: Theme = {
Expand All @@ -36,6 +38,7 @@ const lightTheme: Theme = {
statusGood: '#28a844',
statusWarning: '#ffc007',
statusBad: '#dd3444',
muted: '#757575',
},
};

Expand Down

0 comments on commit d9115fd

Please sign in to comment.