Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/src/common/LastUsedCell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Typography} from '@mui/material';
import React from 'react';
import TimeAgo from 'react-timeago';
import {TimeAgoFormatter} from './TimeAgoFormatter';

export const LastUsedCell: React.FC<{lastUsed: string | null}> = ({lastUsed}) => {
if (lastUsed === null) {
Expand All @@ -11,5 +12,5 @@ export const LastUsedCell: React.FC<{lastUsed: string | null}> = ({lastUsed}) =>
return <Typography title={lastUsed}>Recently</Typography>;
}

return <TimeAgo date={lastUsed} />;
return <TimeAgo date={lastUsed} formatter={TimeAgoFormatter.long} />;
};
7 changes: 7 additions & 0 deletions ui/src/common/TimeAgoFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {Formatter} from 'react-timeago';
import {makeIntlFormatter} from 'react-timeago/defaultFormatter';

export const TimeAgoFormatter: Record<'long' | 'narrow', Formatter> = {
long: makeIntlFormatter({style: 'long', locale: 'en'}),
narrow: makeIntlFormatter({style: 'narrow', locale: 'en'}),
};
6 changes: 3 additions & 3 deletions ui/src/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Markdown} from '../common/Markdown';
import * as config from '../config';
import {IMessageExtras} from '../types';
import {contentType, RenderMode} from './extras';
import {makeIntlFormatter} from 'react-timeago/defaultFormatter';
import {TimeAgoFormatter} from '../common/TimeAgoFormatter';

const PREVIEW_LENGTH = 500;

Expand Down Expand Up @@ -248,7 +248,7 @@ const HeaderWide = ({
</Typography>
</div>
<Typography variant="body1" className={classes.date}>
<TimeAgo date={date} formatter={makeIntlFormatter({style: 'narrow'})} />
<TimeAgo date={date} formatter={TimeAgoFormatter.narrow} />
</Typography>
<IconButton
onClick={fDelete}
Expand Down Expand Up @@ -279,7 +279,7 @@ const HeaderSmall = ({
{appName}
</Typography>
<Typography variant="body1" className={classes.date}>
<TimeAgo date={date} formatter={makeIntlFormatter({style: 'long'})} />
<TimeAgo date={date} formatter={TimeAgoFormatter.long} />
</Typography>
</div>
<div style={{display: 'flex', alignItems: 'end', flexDirection: 'column'}}>
Expand Down
1 change: 1 addition & 0 deletions ui/src/typedef/react-timeago.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare module 'react-timeago' {

export type FormatterOptions = {
style?: 'long' | 'short' | 'narrow';
locale?: string;
};
export type Formatter = (options: FormatterOptions) => React.ReactNode;

Expand Down
Loading