mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
Replace Luxon DateTime with number in ui-notification redux state
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
0d30b599d8
commit
5163cccca4
3 changed files with 6 additions and 4 deletions
|
@ -16,6 +16,7 @@ import { cypressId } from '../../utils/cypress-attribute'
|
||||||
import { useEffectOnce, useInterval } from 'react-use'
|
import { useEffectOnce, useInterval } from 'react-use'
|
||||||
import { dismissUiNotification } from '../../redux/ui-notifications/methods'
|
import { dismissUiNotification } from '../../redux/ui-notifications/methods'
|
||||||
import styles from './notifications.module.scss'
|
import styles from './notifications.module.scss'
|
||||||
|
import { DateTime } from 'luxon'
|
||||||
|
|
||||||
const STEPS_PER_SECOND = 10
|
const STEPS_PER_SECOND = 10
|
||||||
const log = new Logger('UiNotificationToast')
|
const log = new Logger('UiNotificationToast')
|
||||||
|
@ -89,6 +90,8 @@ export const UiNotificationToast: React.FC<UiNotificationProps> = ({
|
||||||
})
|
})
|
||||||
}, [contentI18nKey, contentI18nOptions, t])
|
}, [contentI18nKey, contentI18nOptions, t])
|
||||||
|
|
||||||
|
const formattedDate = useMemo(() => DateTime.fromSeconds(date).toRelative({ style: 'short' }), [date])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Toast className={styles.toast} show={!dismissed} onClose={dismissNow} {...cypressId('notification-toast')}>
|
<Toast className={styles.toast} show={!dismissed} onClose={dismissNow} {...cypressId('notification-toast')}>
|
||||||
<Toast.Header>
|
<Toast.Header>
|
||||||
|
@ -98,7 +101,7 @@ export const UiNotificationToast: React.FC<UiNotificationProps> = ({
|
||||||
</ShowIf>
|
</ShowIf>
|
||||||
<Trans i18nKey={titleI18nKey} tOptions={titleI18nOptions} />
|
<Trans i18nKey={titleI18nKey} tOptions={titleI18nOptions} />
|
||||||
</strong>
|
</strong>
|
||||||
<small>{date.toRelative({ style: 'short' })}</small>
|
<small>{formattedDate}</small>
|
||||||
</Toast.Header>
|
</Toast.Header>
|
||||||
<Toast.Body>{contentDom}</Toast.Body>
|
<Toast.Body>{contentDom}</Toast.Body>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
|
|
@ -42,7 +42,7 @@ export const dispatchUiNotification = async (
|
||||||
notification: {
|
notification: {
|
||||||
titleI18nKey,
|
titleI18nKey,
|
||||||
contentI18nKey,
|
contentI18nKey,
|
||||||
date: DateTime.now(),
|
date: DateTime.now().toSeconds(),
|
||||||
dismissed: false,
|
dismissed: false,
|
||||||
titleI18nOptions: titleI18nOptions ?? {},
|
titleI18nOptions: titleI18nOptions ?? {},
|
||||||
contentI18nOptions: contentI18nOptions ?? {},
|
contentI18nOptions: contentI18nOptions ?? {},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Action } from 'redux'
|
import type { Action } from 'redux'
|
||||||
import type { DateTime } from 'luxon'
|
|
||||||
import type { IconName } from '../../components/common/fork-awesome/types'
|
import type { IconName } from '../../components/common/fork-awesome/types'
|
||||||
import type { TOptions } from 'i18next'
|
import type { TOptions } from 'i18next'
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ export interface DispatchOptions {
|
||||||
export interface UiNotification extends DispatchOptions {
|
export interface UiNotification extends DispatchOptions {
|
||||||
titleI18nKey: string
|
titleI18nKey: string
|
||||||
contentI18nKey: string
|
contentI18nKey: string
|
||||||
date: DateTime
|
date: number
|
||||||
dismissed: boolean
|
dismissed: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue