Rework notifications (#1465)

* Rework notifications

- dispatchUINotification returns a promise that contains the notification id
- notifications use i18n instead of plain text

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Reformat code

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-08-31 22:21:29 +02:00 committed by GitHub
parent 808601eaba
commit 553e9f8ead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 154 additions and 105 deletions

View file

@ -5,23 +5,29 @@
*/
import { useEffect } from 'react'
import { DEFAULT_DURATION_IN_SECONDS, dispatchUiNotification } from '../../redux/ui-notifications/methods'
import { dispatchUiNotification } from '../../redux/ui-notifications/methods'
const localStorageKey = 'dontshowtestnotification'
/**
* Spawns a notification to test the system. Only for tech demo show case.
*/
export const useNotificationTest = (): void => {
useEffect(() => {
if (window.localStorage.getItem(localStorageKey)) {
return
}
console.debug('[Notifications] Dispatched test notification')
dispatchUiNotification('Notification-Test!', 'It Works!', DEFAULT_DURATION_IN_SECONDS, 'info-circle', [
{
label: "Don't show again",
onClick: () => {
window.localStorage.setItem(localStorageKey, '1')
void dispatchUiNotification('notificationTest.title', 'notificationTest.content', {
icon: 'info-circle',
buttons: [
{
label: "Don't show again",
onClick: () => {
window.localStorage.setItem(localStorageKey, '1')
}
}
}
])
]
})
}, [])
}