Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Reapply highlight to unseen notifications #1576

Benjamin Kinga1ba3f62209e
diff --git a/web/js/containers/info.js b/web/js/containers/info.js
index a17232f66..071d72277 100644
--- a/web/js/containers/info.js
+++ b/web/js/containers/info.js
@@ -16,11 +16,6 @@ import { notificationsSeen } from '../modules/notifications/actions';
import util from '../util/util';
import Notifications from '../containers/notifications';
-const NOTIFICATION_CUSTOM_MODAL_PARAMS = {
- headerText: 'Notifications',
- bodyComponent: Notifications
-};
-
class InfoList extends Component {
getNotificationListItem(obj) {
const { number, type, object } = this.props.notifications;
@@ -128,16 +123,17 @@ const mapDispatchToProps = dispatch => ({
}
},
notificationClick: (obj, num) => {
- if (num > 0) {
- dispatch(notificationsSeen());
- addToLocalStorage(obj);
- }
-
dispatch(
- openCustomContent(
- 'NOTIFICATION_LIST_MODAL',
- NOTIFICATION_CUSTOM_MODAL_PARAMS
- )
+ openCustomContent('NOTIFICATION_LIST_MODAL', {
+ headerText: 'Notifications',
+ bodyComponent: Notifications,
+ onClose: () => {
+ if (num > 0) {
+ dispatch(notificationsSeen());
+ addToLocalStorage(obj);
+ }
+ }
+ })
);
},
aboutClick: () => {
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index c083bdd6e..a6e2c3aac 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -43,16 +43,22 @@ class ModalContainer extends Component {
type,
wrapClassName,
clickableBehindModal,
- bodyComponent
+ bodyComponent,
+ onClose
} = newProps;
const style = this.getStyle(newProps);
const lowerCaseId = lodashToLower(id);
const BodyComponent = bodyComponent || '';
-
+ const toggleWithClose = () => {
+ onToggle();
+ if (onClose && isOpen) {
+ onClose();
+ }
+ };
return (
<Modal
isOpen={isOpen}
- toggle={onToggle}
+ toggle={toggleWithClose}
backdrop={backdrop && type !== 'selection'}
id={lowerCaseId}
className={
@@ -63,11 +69,11 @@ class ModalContainer extends Component {
wrapClassName={wrapClassName + ' ' + lowerCaseId}
>
<DetectOuterClick
- onClick={onToggle}
+ onClick={toggleWithClose}
disabled={!isOpen || type === 'selection' || clickableBehindModal}
>
{headerComponent || headerText ? (
- <ModalHeader toggle={onToggle}>
+ <ModalHeader toggle={toggleWithClose}>
{headerComponent ? <headerComponent /> : headerText || ''}
</ModalHeader>
) : (