mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix unlocking items with numbers in paths
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
NotAuthorized,
|
||||
BadRequest,
|
||||
} from '../libs/errors';
|
||||
import setWith from 'lodash.setwith'; // Not available in lodash 3
|
||||
|
||||
// If item is already purchased -> equip it
|
||||
// Otherwise unlock it
|
||||
@@ -60,10 +61,12 @@ module.exports = function unlock (user, req = {}, analytics) {
|
||||
if (isFullSet) {
|
||||
_.each(setPaths, function markItemsAsPurchased (pathPart) {
|
||||
if (path.indexOf('gear.') !== -1) {
|
||||
_.set(user, pathPart, true);
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
setWith(user, pathPart, true);
|
||||
}
|
||||
|
||||
_.set(user, `purchased.${pathPart}`, true);
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
setWith(user, `purchased.${pathPart}`, true, Object);
|
||||
});
|
||||
} else {
|
||||
if (alreadyOwns) { // eslint-disable-line no-lonely-if
|
||||
@@ -74,9 +77,11 @@ module.exports = function unlock (user, req = {}, analytics) {
|
||||
value = '';
|
||||
}
|
||||
|
||||
_.set(user, `preferences.${key}`, value);
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
setWith(user, `preferences.${key}`, value);
|
||||
} else {
|
||||
_.set(user, `purchased.${path}`, true);
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
setWith(user, `purchased.${path}`, true, Object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
"jade": "~1.11.0",
|
||||
"js2xmlparser": "~1.0.0",
|
||||
"lodash": "^3.10.1",
|
||||
"lodash.setwith": "^4.2.0",
|
||||
"loggly": "~1.0.8",
|
||||
"markdown-it": "^6.0.1",
|
||||
"merge-stream": "^1.0.0",
|
||||
|
||||
Reference in New Issue
Block a user