Replace Luxon DateTime with number in ui-notification redux state

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-05-09 20:24:20 +02:00
parent 0d30b599d8
commit 5163cccca4
3 changed files with 6 additions and 4 deletions

View file

@ -16,6 +16,7 @@ import { cypressId } from '../../utils/cypress-attribute'
import { useEffectOnce, useInterval } from 'react-use'
import { dismissUiNotification } from '../../redux/ui-notifications/methods'
import styles from './notifications.module.scss'
import { DateTime } from 'luxon'
const STEPS_PER_SECOND = 10
const log = new Logger('UiNotificationToast')
@ -89,6 +90,8 @@ export const UiNotificationToast: React.FC<UiNotificationProps> = ({
})
}, [contentI18nKey, contentI18nOptions, t])
const formattedDate = useMemo(() => DateTime.fromSeconds(date).toRelative({ style: 'short' }), [date])
return (
<Toast className={styles.toast} show={!dismissed} onClose={dismissNow} {...cypressId('notification-toast')}>
<Toast.Header>
@ -98,7 +101,7 @@ export const UiNotificationToast: React.FC<UiNotificationProps> = ({
</ShowIf>
<Trans i18nKey={titleI18nKey} tOptions={titleI18nOptions} />
</strong>
<small>{date.toRelative({ style: 'short' })}</small>
<small>{formattedDate}</small>
</Toast.Header>
<Toast.Body>{contentDom}</Toast.Body>
<ProgressBar

View file

@ -42,7 +42,7 @@ export const dispatchUiNotification = async (
notification: {
titleI18nKey,
contentI18nKey,
date: DateTime.now(),
date: DateTime.now().toSeconds(),
dismissed: false,
titleI18nOptions: titleI18nOptions ?? {},
contentI18nOptions: contentI18nOptions ?? {},

View file

@ -5,7 +5,6 @@
*/
import type { Action } from 'redux'
import type { DateTime } from 'luxon'
import type { IconName } from '../../components/common/fork-awesome/types'
import type { TOptions } from 'i18next'
@ -30,7 +29,7 @@ export interface DispatchOptions {
export interface UiNotification extends DispatchOptions {
titleI18nKey: string
contentI18nKey: string
date: DateTime
date: number
dismissed: boolean
}