File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed
Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 11import { Typography } from '@mui/material' ;
22import React from 'react' ;
33import TimeAgo from 'react-timeago' ;
4+ import { TimeAgoFormatter } from './TimeAgoFormatter' ;
45
56export const LastUsedCell : React . FC < { lastUsed : string | null } > = ( { lastUsed} ) => {
67 if ( lastUsed === null ) {
@@ -11,5 +12,5 @@ export const LastUsedCell: React.FC<{lastUsed: string | null}> = ({lastUsed}) =>
1112 return < Typography title = { lastUsed } > Recently</ Typography > ;
1213 }
1314
14- return < TimeAgo date = { lastUsed } /> ;
15+ return < TimeAgo date = { lastUsed } formatter = { TimeAgoFormatter . long } /> ;
1516} ;
Original file line number Diff line number Diff line change 1+ import { Formatter } from 'react-timeago' ;
2+ import { makeIntlFormatter } from 'react-timeago/defaultFormatter' ;
3+
4+ export const TimeAgoFormatter : Record < 'long' | 'narrow' , Formatter > = {
5+ long : makeIntlFormatter ( { style : 'long' , locale : 'en' } ) ,
6+ narrow : makeIntlFormatter ( { style : 'narrow' , locale : 'en' } ) ,
7+ } ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {Markdown} from '../common/Markdown';
1111import * as config from '../config' ;
1212import { IMessageExtras } from '../types' ;
1313import { contentType , RenderMode } from './extras' ;
14- import { makeIntlFormatter } from 'react-timeago/defaultFormatter ' ;
14+ import { TimeAgoFormatter } from '../common/TimeAgoFormatter ' ;
1515
1616const PREVIEW_LENGTH = 500 ;
1717
@@ -248,7 +248,7 @@ const HeaderWide = ({
248248 </ Typography >
249249 </ div >
250250 < Typography variant = "body1" className = { classes . date } >
251- < TimeAgo date = { date } formatter = { makeIntlFormatter ( { style : ' narrow' } ) } />
251+ < TimeAgo date = { date } formatter = { TimeAgoFormatter . narrow } />
252252 </ Typography >
253253 < IconButton
254254 onClick = { fDelete }
@@ -279,7 +279,7 @@ const HeaderSmall = ({
279279 { appName }
280280 </ Typography >
281281 < Typography variant = "body1" className = { classes . date } >
282- < TimeAgo date = { date } formatter = { makeIntlFormatter ( { style : ' long' } ) } />
282+ < TimeAgo date = { date } formatter = { TimeAgoFormatter . long } />
283283 </ Typography >
284284 </ div >
285285 < div style = { { display : 'flex' , alignItems : 'end' , flexDirection : 'column' } } >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ declare module 'react-timeago' {
33
44 export type FormatterOptions = {
55 style ?: 'long' | 'short' | 'narrow' ;
6+ locale ?: string ;
67 } ;
78 export type Formatter = ( options : FormatterOptions ) => React . ReactNode ;
89
You can’t perform that action at this time.
0 commit comments