Move all firbase dependencies from actions layer to firebaseService layer (#13)
This commit is contained in:
@@ -6,16 +6,15 @@ import _ from 'lodash'
|
||||
import { Notification } from 'domain/notifications'
|
||||
|
||||
// - Import action types
|
||||
import {NotificationActionType} from 'constants/notificationActionType'
|
||||
import { NotificationActionType } from 'constants/notificationActionType'
|
||||
|
||||
import { NotificationState } from './NotificationState'
|
||||
import { INotificationAction } from './INotificationAction'
|
||||
|
||||
|
||||
/**
|
||||
* Notify actions
|
||||
* @param {object} state
|
||||
* @param {object} action
|
||||
* @param {object} state
|
||||
* @param {object} action
|
||||
*/
|
||||
export let notificationReducer = (state: NotificationState = new NotificationState(), action: INotificationAction) => {
|
||||
let { payload } = action
|
||||
@@ -24,29 +23,29 @@ export let notificationReducer = (state: NotificationState = new NotificationSta
|
||||
/* _____________ CRUD _____________ */
|
||||
case NotificationActionType.ADD_NOTIFY:
|
||||
return state
|
||||
|
||||
|
||||
case NotificationActionType.ADD_NOTIFY_LIST:
|
||||
return {
|
||||
...state,
|
||||
userNotifies: {
|
||||
...payload
|
||||
},
|
||||
loaded:true
|
||||
loaded: true
|
||||
}
|
||||
|
||||
case NotificationActionType.SEEN_NOTIFY:
|
||||
case NotificationActionType.SEEN_NOTIFY:
|
||||
return {
|
||||
...state,
|
||||
userNotifies: {
|
||||
...state.userNotifies,
|
||||
[payload]:{
|
||||
[payload]: {
|
||||
...state.userNotifies![payload],
|
||||
isSeen:true
|
||||
isSeen: true
|
||||
}
|
||||
},
|
||||
loaded:true
|
||||
loaded: true
|
||||
}
|
||||
|
||||
|
||||
case NotificationActionType.DELETE_NOTIFY:
|
||||
let parsedNotifies = {}
|
||||
Object.keys(state.userNotifies!).map((id) => {
|
||||
@@ -58,19 +57,16 @@ export let notificationReducer = (state: NotificationState = new NotificationSta
|
||||
return {
|
||||
...state,
|
||||
userNotifies: {
|
||||
...parsedNotifies
|
||||
...parsedNotifies
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
case NotificationActionType.CLEAR_ALL_DATA_NOTIFY:
|
||||
return new NotificationState()
|
||||
|
||||
|
||||
default:
|
||||
return state
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user