mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
change mobile filter defaults to a list
This commit is contained in:
committed by
Sabe Jones
parent
f99ddbe60f
commit
d11e95ab26
@@ -6,10 +6,14 @@ const IS_PROD = nconf.get('IS_PROD');
|
|||||||
|
|
||||||
const api = {};
|
const api = {};
|
||||||
|
|
||||||
const MOBILE_FILTER = `achievements,questSeriesAchievements,animalColorAchievements,animalSetAchievements,stableAchievements,
|
const MOBILE_FILTER = ['achievements', 'questSeriesAchievements', 'animalColorAchievements', 'animalSetAchievements',
|
||||||
mystery,bundles,loginIncentives,pets,premiumPets,specialPets,questPets,wackyPets,mounts,premiumMounts,specialMounts,questMounts,
|
'stableAchievements', 'mystery', 'bundles', 'loginIncentives', 'pets', 'premiumPets', 'specialPets', 'questPets',
|
||||||
events,dropEggs,questEggs,dropHatchingPotions,premiumHatchingPotions,wackyHatchingPotions,backgroundsFlat,questsByLevel,gear.tree,
|
'wackyPets', 'mounts', 'premiumMounts,specialMounts,questMounts', 'events', 'dropEggs', 'questEggs', 'dropHatchingPotions',
|
||||||
tasksByCategory,userDefaults,timeTravelStable,gearTypes,cardTypes`;
|
'premiumHatchingPotions', 'wackyHatchingPotions', 'backgroundsFlat', 'questsByLevel', 'gear.tree', 'tasksByCategory',
|
||||||
|
'userDefaults', 'timeTravelStable', 'gearTypes', 'cardTypes'];
|
||||||
|
|
||||||
|
const ANDROID_FILTER = [...MOBILE_FILTER, 'appearances.background'];
|
||||||
|
const IOS_FILTER = [...MOBILE_FILTER, 'backgrounds'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /api/v3/content Get all available content objects
|
* @api {get} /api/v3/content Get all available content objects
|
||||||
@@ -70,17 +74,20 @@ api.getContent = {
|
|||||||
language = proposedLang;
|
language = proposedLang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let filter_list = [];
|
||||||
let filter = req.query.filter || '';
|
let filter = req.query.filter || '';
|
||||||
// apply defaults for mobile clients
|
// apply defaults for mobile clients
|
||||||
if (filter === '') {
|
if (filter === '') {
|
||||||
if (req.headers['x-client'] === 'habitica-android') {
|
if (req.headers['x-client'] === 'habitica-android') {
|
||||||
filter = `${MOBILE_FILTER},appearances.background`;
|
filter_list = ANDROID_FILTER;
|
||||||
} else if (req.headers['x-client'] === 'habitica-ios') {
|
} else if (req.headers['x-client'] === 'habitica-ios') {
|
||||||
filter = `${MOBILE_FILTER},backgrounds`;
|
filter_list = IOS_FILTER;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
filter_list = filter.split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
serveContent(res, language, filter, IS_PROD);
|
serveContent(res, language, filter_list, IS_PROD);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function hashForFilter (filter) {
|
|||||||
export function serveContent (res, language, filter, isProd) {
|
export function serveContent (res, language, filter, isProd) {
|
||||||
// Build usable filter object
|
// Build usable filter object
|
||||||
const filterObj = {};
|
const filterObj = {};
|
||||||
filter.split(',').forEach(item => {
|
filter.forEach(item => {
|
||||||
if (item.includes('.')) {
|
if (item.includes('.')) {
|
||||||
const [key, subkey] = item.split('.');
|
const [key, subkey] = item.split('.');
|
||||||
if (!filterObj[key]) {
|
if (!filterObj[key]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user