mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
item pinning (#8918)
* toggle pinned state of items server + client * pin quests / add pin src * add officially pinned items and api to get in app rewards * update schema and get items deatils * update pin actions to the new logic * show countBadge only with a number * extract getPinKey - pin seasonal items * togglePinned in buy-dialogs * add pinKey to shop items * wip * wip * fix path * togglePinnedItem as common.op / use in client * fix linting * pinning: getItemInfo and save in db path and type * make api more consistent, fix bugs * updates * fix bugs * update actions to current api * marketGear * change to pinType * add mystery_set to getItemInfo * fix isPinned * ignore animals * list shopItems (initial) * shopItem now has default popoverconent, itemclass and price / currency - list pinned items as rewards - attributes to gear * show buyModal for the rewards * show mystery_set icon * add info whether item is suggested * write migration, fix style issues * pin potion and armoire * make potion, armoire not unpinnable * show notes for armoire and potion, add default items for new users * show unpin notification * add/remove pinned gear on class-change * remove pinned & add new gear on purchase - refactoring pinning methods - fixes * always allow to purchase armoire * highlight item if suggested
This commit is contained in:
@@ -134,6 +134,49 @@ api.getBuyList = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {get} /api/v3/user/in-app-rewards Get the in app items appaearing in the user's reward column
|
||||
* @apiName UserGetInAppRewards
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {
|
||||
* "success": true,
|
||||
* "data": [
|
||||
* {
|
||||
* "key":"weapon_armoire_battleAxe",
|
||||
* "text":"Battle Axe",
|
||||
* "notes":"This fine iron axe is well-suited to battling your fiercest foes or your most difficult tasks. Increases Intelligence by 6 and Constitution by 8. Enchanted Armoire: Independent Item.",
|
||||
* "value":1,
|
||||
* "type":"weapon",
|
||||
* "locked":false,
|
||||
* "currency":"gems",
|
||||
* "purchaseType":"gear",
|
||||
* "class":"shop_weapon_armoire_battleAxe",
|
||||
* "path":"gear.flat.weapon_armoire_battleAxe",
|
||||
* "pinType":"gear"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
api.getInAppRewardsList = {
|
||||
method: 'GET',
|
||||
middlewares: [authWithHeaders()],
|
||||
url: '/user/in-app-rewards',
|
||||
async handler (req, res) {
|
||||
let list = common.inAppRewards(res.locals.user);
|
||||
|
||||
// return text and notes strings
|
||||
_.each(list, item => {
|
||||
_.each(item, (itemPropVal, itemPropKey) => {
|
||||
if (_.isFunction(itemPropVal) && itemPropVal.i18nLangFunc) item[itemPropKey] = itemPropVal(req.language);
|
||||
});
|
||||
});
|
||||
|
||||
res.respond(200, list);
|
||||
},
|
||||
};
|
||||
|
||||
let updatablePaths = [
|
||||
'_ABtests.counter',
|
||||
|
||||
@@ -1958,4 +2001,45 @@ api.setCustomDayStart = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @api {get} /user/toggle-pinned-item/:key Toggle an item to be pinned
|
||||
* @apiName togglePinnedItem
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiSuccess {Object} data Pinned items array
|
||||
*
|
||||
* @apiSuccessExample {json} Result:
|
||||
* {
|
||||
* "success": true,
|
||||
* "data": {
|
||||
* "pinnedItems": [
|
||||
* "type": "gear",
|
||||
* "path": "gear.flat.weapon_1"
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
api.togglePinnedItem = {
|
||||
method: 'GET',
|
||||
middlewares: [authWithHeaders()],
|
||||
url: '/user/toggle-pinned-item/:type/:path',
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
const path = get(req.params, 'path');
|
||||
const type = get(req.params, 'type');
|
||||
|
||||
common.ops.pinnedGearUtils.togglePinnedItem(user, {type, path}, req);
|
||||
|
||||
await user.save();
|
||||
|
||||
let userJson = user.toJSON();
|
||||
|
||||
res.respond(200, {
|
||||
pinnedItems: userJson.pinnedItems,
|
||||
unpinnedItems: userJson.unpinnedItems,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
|
||||
Reference in New Issue
Block a user