Skip to content

Commit fefcf84

Browse files
committed
Bring notifs code into application and update deps
1 parent f56d4ba commit fefcf84

File tree

17 files changed

+241
-152
lines changed

17 files changed

+241
-152
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ node_modules
2929
# Bower
3030
bower_components/
3131

32-
.env
32+
.env
33+
34+
.DS_Store

package-lock.json

Lines changed: 22 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"normalize.css": "^4.0.0",
9494
"normalizr": "^3.4.1",
9595
"react": "^16.12.0",
96+
"react-addons-css-transition-group": "^15.6.2",
9697
"react-bootstrap": "^1.0.0-beta.16",
9798
"react-dom": "^16.12.0",
9899
"react-hot-loader": "^3.0.0-beta.5",
@@ -109,7 +110,6 @@
109110
"react-waypoint": "^9.0.2",
110111
"redux": "^4.0.4",
111112
"redux-form": "^8.2.6",
112-
"redux-notifications": "^4.0.1",
113113
"redux-thunk": "^2.3.0",
114114
"reselect": "^4.0.0"
115115
}

src/actions/artwork/deleteArtworkSuccess.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {DELETE_ARTWORK_SUCCESS} from './../const';
2-
import { actions as notifActions } from 'redux-notifications';
3-
const { notifSend } = notifActions;
2+
import { notifSend } from '../notifications';
43

54
export default function(artwork) {
65
return (dispatch) => {

src/actions/frame/deleteFrameSuccess.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {DELETE_FRAME_SUCCESS} from './../const';
22
import { unbindFrameEvents } from '../../services/pubsub';
3-
import { actions as notifActions } from 'redux-notifications';
4-
const { notifSend } = notifActions;
3+
import { notifSend } from '../notifications';
54

65
export default function(frame) {
76
return (dispatch) => {

src/actions/frame/updateCurrentArtworkSuccess.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@ import {UPDATE_CURRENT_ARTWORK_SUCCESS} from './../const';
22

33
import { normalize } from 'normalizr';
44
import * as schema from '../schema';
5-
// import { actions as notifActions } from 'redux-notifications';
6-
// const { notifSend } = notifActions;
75

86
export default function(response) {
97
return dispatch => {
108
let frame = response;
119
dispatch({ type: UPDATE_CURRENT_ARTWORK_SUCCESS, response: normalize(frame, schema.frame) });
12-
// let notification = {
13-
// message: 'Current artwork updated.',
14-
// kind: 'info',
15-
// dismissAfter: 5000
16-
// }
17-
// dispatch(notifSend(notification));
18-
1910
}
2011
};

src/actions/notifications.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const objectAssign = require('object-assign');
2+
3+
export const NOTIF_SEND = 'NOTIF_SEND';
4+
export const NOTIF_DISMISS = 'NOTIF_DISMISS';
5+
export const NOTIF_CLEAR = 'NOTIF_CLEAR';
6+
7+
/**
8+
* Publish a notification,
9+
* - if `dismissAfter` was set, the notification will be auto dismissed after the given period.
10+
* - if id wasn't specified, a time based id will be generated.``
11+
*/
12+
export function notifSend(notif) {
13+
const payload = objectAssign({}, notif);
14+
if (!payload.id) {
15+
payload.id = new Date().getTime();
16+
}
17+
return dispatch => {
18+
dispatch({ type: NOTIF_SEND, payload });
19+
20+
if (payload.dismissAfter) {
21+
setTimeout(() => {
22+
dispatch({
23+
type: NOTIF_DISMISS,
24+
payload: payload.id,
25+
});
26+
}, payload.dismissAfter);
27+
}
28+
};
29+
}
30+
31+
/**
32+
* Dismiss a notification by the given id.
33+
*/
34+
export function notifDismiss(id) {
35+
return { type: NOTIF_DISMISS, payload: id };
36+
}
37+
38+
/**
39+
* Clear all notifications
40+
*/
41+
export function notifClear() {
42+
return { type: NOTIF_CLEAR };
43+
}

src/actions/user/removeFromFrameSuccess.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {REMOVE_FROM_FRAME_SUCCESS} from './../const';
22
import { unbindFrameEvents } from '../../services/pubsub';
3-
import { actions as notifActions } from 'redux-notifications';
4-
const { notifSend } = notifActions;
3+
import { notifSend } from '../notifications';
54

65
export default function(frame) {
76
return (dispatch, getState) => {

src/actions/user/updateUserSuccess.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { normalize } from 'normalizr';
22
import {UPDATE_USER_SUCCESS} from './../const';
33
import * as schema from '../schema';
4-
import { actions as notifActions } from 'redux-notifications';
5-
const { notifSend } = notifActions;
4+
import { notifSend } from '../notifications';
65

76
export default function(response, notice) {
87
return dispatch => {

0 commit comments

Comments
 (0)