Move all firbase dependencies from actions layer to firebaseService layer (#13)

This commit is contained in:
Qolzam
2017-10-12 17:47:26 +07:00
parent c82826bdd4
commit 0785c38d42
48 changed files with 1305 additions and 796 deletions

View File

@@ -1,26 +1,25 @@
import { Circle } from 'domain/circles'
/**
* Circle state
*
* Circle state
*
* @export
* @class CircleState
*/
export class CircleState {
export class CircleState {
/**
* The list of Circles belong to users
*
*
* @type {({[userId: string]: {[circleId: string]: Circle}} | null)}
* @memberof CircleState
*/
userCircles: {[userId: string]: {[circleId: string]: Circle}} = {}
userCircles: {[userId: string]: {[circleId: string]: Circle}} = {}
/**
* If user circles are loaded {true} or not {false}
*
*
* @type {Boolean}
* @memberof CircleState
*/
loaded: Boolean = false
}
loaded: Boolean = false
}

View File

@@ -7,16 +7,15 @@ import { User } from 'domain/users'
import { Comment } from 'domain/comments'
// - Import action types
import {CommentActionType} from 'constants/commentActionType'
import { CommentActionType } from 'constants/commentActionType'
import { CommentState } from './CommentState'
import { ICommentAction } from './ICommentAction'
/**
* Comment reducer
* @param state
* @param action
* @param state
* @param action
*/
export let commentReducer = (state: CommentState = new CommentState(), action: ICommentAction) => {
let { payload } = action
@@ -31,7 +30,7 @@ export let commentReducer = (state: CommentState = new CommentState(), action: I
[payload.postId]: {
...state.postComments![payload.postId],
[payload.id]: {
...payload.comment,
...payload,
editorStatus: false
}
}
@@ -44,7 +43,7 @@ export let commentReducer = (state: CommentState = new CommentState(), action: I
postComments: {
...payload
},
loaded:true
loaded: true
}
case CommentActionType.UPDATE_COMMENT:
return {
@@ -112,12 +111,9 @@ export let commentReducer = (state: CommentState = new CommentState(), action: I
case CommentActionType.CLEAR_ALL_DATA_COMMENT:
return new CommentState()
default:
return state
}
}

View File

@@ -1,13 +1,13 @@
import {ImageGalleryActionType} from 'constants/imageGalleryActionType'
import { ImageGalleryActionType } from 'constants/imageGalleryActionType'
/**
* ImageGallery action interface
*
*
* @export
* @interface IImageGalleryAction
*/
export interface IImageGalleryAction {
payload: any,
type: ImageGalleryActionType
}
export interface IImageGalleryAction {
payload: any,
type: ImageGalleryActionType
}

View File

@@ -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
}
}

View File

@@ -1,13 +1,13 @@
import {UserActionType} from 'constants/userActionType'
import { UserActionType } from 'constants/userActionType'
/**
* User action interface
*
*
* @export
* @interface IUserAction
*/
export interface IUserAction {
payload: any,
type: UserActionType
}
export interface IUserAction {
payload: any,
type: UserActionType
}