Don't dismiss ServiceWorker snackbar
This commit is contained in:
parent
82122ffe45
commit
23c37229b8
|
@ -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 = (
|
||||||
|
|
|
@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ function main() {
|
||||||
action: () => {
|
action: () => {
|
||||||
OfflinePluginRuntime.applyUpdate();
|
OfflinePluginRuntime.applyUpdate();
|
||||||
},
|
},
|
||||||
|
dismissAfter: false,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
onUpdated: function() {
|
onUpdated: function() {
|
||||||
|
|
|
@ -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';
|
||||||
|
|
Loading…
Reference in New Issue