From 9bf565d2f4790e1f2f83496b3e65cfb8129632e0 Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 13 Mar 2018 19:03:51 -0700 Subject: [PATCH] Clean up notifications reducer --- ui/src/shared/reducers/notifications.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ui/src/shared/reducers/notifications.js b/ui/src/shared/reducers/notifications.js index 0b3bde8f2c..41bce6028d 100644 --- a/ui/src/shared/reducers/notifications.js +++ b/ui/src/shared/reducers/notifications.js @@ -4,13 +4,15 @@ export const initialState = [] export const notifications = (state = initialState, action) => { switch (action.type) { case 'PUBLISH_NOTIFICATION': { - const notification = { - ...action.payload.notification, - id: uuid.v4(), - } - const newNotification = [notification] - // Hacky way to add the new notifcation to the front of the list - return [...newNotification, ...state] + const {notifcation} = action.payload + const publishedNotification = [ + { + ...notifcation, + id: uuid.v4(), + }, + ] + + return [...publishedNotification, ...state] } case 'DISMISS_NOTIFICATION': {