Don't dismiss ServiceWorker snackbar

This commit is contained in:
Alex Gleason 2022-06-23 18:03:35 -05:00
parent 82122ffe45
commit 23c37229b8
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 6 additions and 3 deletions

View File

@ -19,6 +19,7 @@ type SnackbarOpts = {
actionLabel?: SnackbarMessage, actionLabel?: SnackbarMessage,
actionLink?: string, actionLink?: string,
action?: () => void, action?: () => void,
dismissAfter?: number | false,
}; };
export const show = ( export const show = (

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { useIntl } from 'react-intl'; import { useIntl, MessageDescriptor } from 'react-intl';
import { NotificationStack, NotificationObject, StyleFactoryFn } from 'react-notification'; import { NotificationStack, NotificationObject, StyleFactoryFn } from 'react-notification';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@ -18,7 +18,7 @@ const SnackbarContainer: React.FC = () => {
const alerts = useAppSelector(state => state.alerts); const alerts = useAppSelector(state => state.alerts);
/** Apply i18n to the message if it's an object. */ /** Apply i18n to the message if it's an object. */
const maybeFormatMessage = (message: any): string => { const maybeFormatMessage = (message: MessageDescriptor | string): string => {
switch (typeof message) { switch (typeof message) {
case 'string': return message; case 'string': return message;
case 'object': return intl.formatMessage(message); case 'object': return intl.formatMessage(message);
@ -39,7 +39,7 @@ const SnackbarContainer: React.FC = () => {
key: item.key, key: item.key,
className: `notification-bar-${item.severity}`, className: `notification-bar-${item.severity}`,
activeClassName: 'snackbar--active', activeClassName: 'snackbar--active',
dismissAfter: 6000, dismissAfter: item.dismissAfter,
style: false, style: false,
}; };

View File

@ -47,6 +47,7 @@ function main() {
action: () => { action: () => {
OfflinePluginRuntime.applyUpdate(); OfflinePluginRuntime.applyUpdate();
}, },
dismissAfter: false,
})); }));
}, },
onUpdated: function() { onUpdated: function() {

View File

@ -14,6 +14,7 @@ const AlertRecord = ImmutableRecord({
actionLabel: '', actionLabel: '',
actionLink: '', actionLink: '',
action: () => {}, action: () => {},
dismissAfter: 6000 as number | false,
}); });
import type { AnyAction } from 'redux'; import type { AnyAction } from 'redux';