diff --git a/app/soapbox/actions/snackbar.ts b/app/soapbox/actions/snackbar.ts index 071c61c4f..57d23b64b 100644 --- a/app/soapbox/actions/snackbar.ts +++ b/app/soapbox/actions/snackbar.ts @@ -19,6 +19,7 @@ type SnackbarOpts = { actionLabel?: SnackbarMessage, actionLink?: string, action?: () => void, + dismissAfter?: number | false, }; export const show = ( diff --git a/app/soapbox/features/ui/containers/notifications_container.tsx b/app/soapbox/features/ui/containers/notifications_container.tsx index 566acffbb..eafd8efe4 100644 --- a/app/soapbox/features/ui/containers/notifications_container.tsx +++ b/app/soapbox/features/ui/containers/notifications_container.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { useIntl } from 'react-intl'; +import { useIntl, MessageDescriptor } from 'react-intl'; import { NotificationStack, NotificationObject, StyleFactoryFn } from 'react-notification'; import { useHistory } from 'react-router-dom'; @@ -18,7 +18,7 @@ const SnackbarContainer: React.FC = () => { const alerts = useAppSelector(state => state.alerts); /** Apply i18n to the message if it's an object. */ - const maybeFormatMessage = (message: any): string => { + const maybeFormatMessage = (message: MessageDescriptor | string): string => { switch (typeof message) { case 'string': return message; case 'object': return intl.formatMessage(message); @@ -39,7 +39,7 @@ const SnackbarContainer: React.FC = () => { key: item.key, className: `notification-bar-${item.severity}`, activeClassName: 'snackbar--active', - dismissAfter: 6000, + dismissAfter: item.dismissAfter, style: false, }; diff --git a/app/soapbox/main.tsx b/app/soapbox/main.tsx index 2ae1212f0..9456d9aa3 100644 --- a/app/soapbox/main.tsx +++ b/app/soapbox/main.tsx @@ -47,6 +47,7 @@ function main() { action: () => { OfflinePluginRuntime.applyUpdate(); }, + dismissAfter: false, })); }, onUpdated: function() { diff --git a/app/soapbox/reducers/alerts.ts b/app/soapbox/reducers/alerts.ts index ac290e0fa..b81c01b7f 100644 --- a/app/soapbox/reducers/alerts.ts +++ b/app/soapbox/reducers/alerts.ts @@ -14,6 +14,7 @@ const AlertRecord = ImmutableRecord({ actionLabel: '', actionLink: '', action: () => {}, + dismissAfter: 6000 as number | false, }); import type { AnyAction } from 'redux';