-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from FuelRats/develop
v2.12.8 - The one where we actually fixed decals for real this time I swear
- Loading branch information
Showing
6 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { isError } from 'flux-standard-action' | ||
import { produce } from 'immer' | ||
|
||
import safeParseInt from '~/helpers/safeParseInt' | ||
|
||
import actionTypes from '../actionTypes' | ||
import initialState from '../initialState' | ||
|
||
const metaKey = '__decals/decrement' | ||
|
||
const usersReducer = produce((draftState, action) => { | ||
if (isError(action)) { | ||
return | ||
} | ||
|
||
switch (action.type) { | ||
case actionTypes.decals.redeem: | ||
if (action.meta[metaKey]) { | ||
const user = draftState[action.meta[metaKey]] | ||
if (user?.meta) { | ||
user.meta.redeemable = Math.max(safeParseInt(user.meta.redeemable) - 1, 0) | ||
} | ||
} | ||
break | ||
|
||
default: | ||
break | ||
} | ||
}, initialState.users) | ||
|
||
|
||
|
||
export function decrementsEligibleDecals (id) { | ||
return { | ||
[metaKey]: id, | ||
} | ||
} | ||
|
||
|
||
export default usersReducer |