mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { store } from '../index'
|
|
import {
|
|
DismissUiNotificationAction,
|
|
DispatchUiNotificationAction,
|
|
UiNotificationActionType,
|
|
UiNotificationButton
|
|
} from './types'
|
|
import { DateTime } from 'luxon'
|
|
import { IconName } from '../../components/common/fork-awesome/types'
|
|
|
|
export const DEFAULT_DURATION_IN_SECONDS = 10
|
|
|
|
export const dispatchUiNotification = (title: string, content: string, durationInSecond = DEFAULT_DURATION_IN_SECONDS, icon?: IconName, buttons?: UiNotificationButton[]): void => {
|
|
store.dispatch({
|
|
type: UiNotificationActionType.DISPATCH_NOTIFICATION,
|
|
notification: {
|
|
title,
|
|
content,
|
|
date: DateTime.now(),
|
|
dismissed: false,
|
|
icon,
|
|
durationInSecond,
|
|
buttons: buttons
|
|
}
|
|
} as DispatchUiNotificationAction)
|
|
}
|
|
|
|
export const dismissUiNotification = (notificationId: number): void => {
|
|
store.dispatch({
|
|
type: UiNotificationActionType.DISMISS_NOTIFICATION,
|
|
notificationId
|
|
} as DismissUiNotificationAction)
|
|
}
|