feat: Create and use dynamic active donation counts

This commit is contained in:
Bouncey
2018-11-29 14:24:17 +00:00
committed by mrugesh mohapatra
parent 331ea3ebf9
commit 8fab33ba99
6 changed files with 111 additions and 58 deletions

View File

@@ -39,6 +39,7 @@ const initialState = {
userProfileFetchState: {
...defaultFetchState
},
sessionMeta: {},
showDonationModal: false,
isOnline: true
};
@@ -158,6 +159,13 @@ export const userSelector = state => {
return state[ns].user[username] || {};
};
export const sessionMetaSelector = state => state[ns].sessionMeta;
export const activeDonationsSelector = state =>
// this default is mostly for development where there are likely no donators
// in the local db
// If we see this in production then things are getting weird
sessionMetaSelector(state).activeDonations || 4040;
function spreadThePayloadOnUser(state, payload) {
return {
...state,
@@ -181,7 +189,10 @@ export const reducer = handleActions(
...state,
userProfileFetchState: { ...defaultFetchState }
}),
[types.fetchUserComplete]: (state, { payload: { user, username } }) => ({
[types.fetchUserComplete]: (
state,
{ payload: { user, username, sessionMeta } }
) => ({
...state,
user: {
...state.user,
@@ -193,6 +204,10 @@ export const reducer = handleActions(
complete: true,
errored: false,
error: null
},
sessionMeta: {
...state.sessionMeta,
...sessionMeta
}
}),
[types.fetchUserError]: (state, { payload }) => ({