Skip to content

Commit

Permalink
Merge pull request #910 from WatWowMap/fix-perm-subcategory-viewing
Browse files Browse the repository at this point in the history
fix: subcategory viewing
  • Loading branch information
TurtIeSocks authored Jan 7, 2024
2 parents 41cb8f7 + 3ed2e8f commit ec40756
Showing 1 changed file with 41 additions and 34 deletions.
75 changes: 41 additions & 34 deletions server/src/services/ui/primary.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ leagues.forEach((league) =>
}),
)

// TODO this will be used later in the config
const BLOCKED = undefined

/**
*
* @param {import('express').Request} req
Expand All @@ -98,41 +101,45 @@ function generateUi(req, perms) {
gyms:
(perms.gyms || perms.raids) && Db.models.Gym
? {
allGyms: true,
raids: perms.raids,
exEligible: true,
inBattle: true,
arEligible: true,
gymBadges: perms.gymBadges,
allGyms: perms.gyms || BLOCKED,
raids: perms.raids || BLOCKED,
exEligible: perms.gyms || BLOCKED,
inBattle: perms.gyms || BLOCKED,
arEligible: perms.gyms || BLOCKED,
gymBadges: perms.gymBadges || BLOCKED,
}
: undefined,
: BLOCKED,
nests:
perms.nests && Db.models.Nest
? { pokemon: true, polygons: true, sliders: SLIDERS.nests }
: undefined,
? {
pokemon: true,
polygons: true,
sliders: SLIDERS.nests,
}
: BLOCKED,
pokestops:
(perms.pokestops || perms.lures || perms.quests || perms.invasions) &&
Db.models.Pokestop
? {
allPokestops: perms.pokestops,
lures: perms.lures,
eventStops: perms.eventStops,
quests: perms.quests,
invasions: perms.invasions,
arEligible: perms.pokestops,
allPokestops: perms.pokestops || BLOCKED,
lures: perms.lures || BLOCKED,
eventStops: perms.eventStops || BLOCKED,
quests: perms.quests || BLOCKED,
invasions: perms.invasions || BLOCKED,
arEligible: perms.pokestops || BLOCKED,
}
: undefined,
: BLOCKED,
pokemon:
(perms.pokemon || perms.iv || perms.pvp) && Db.models.Pokemon
? {
legacy: mapConfig.misc.enableMapJsFilter,
iv: perms.iv,
pvp: perms.pvp,
standard: true,
ivOr: true,
gender: true,
zeroIv: perms.iv,
hundoIv: perms.iv,
legacy: perms.iv && mapConfig.misc.enableMapJsFilter,
iv: perms.iv || BLOCKED,
pvp: perms.pvp || BLOCKED,
// standard: true,
// ivOr: true,
// gender: true,
zeroIv: perms.iv || BLOCKED,
hundoIv: perms.iv || BLOCKED,
sliders: {
primary: SLIDERS.pokemon.primary.map((slider) => ({
...slider,
Expand All @@ -144,34 +151,34 @@ function generateUi(req, perms) {
})),
},
}
: undefined,
routes: perms.routes && Db.models.Route ? { enabled: true } : undefined,
: BLOCKED,
routes: perms.routes && Db.models.Route ? { enabled: true } : BLOCKED,
wayfarer:
perms.portals || perms.submissionCells
? {
portals: !!(perms.portals && Db.models.Portal) || undefined,
portals: !!(perms.portals && Db.models.Portal) || BLOCKED,
submissionCells:
!!(
perms.submissionCells &&
Db.models.Pokestop &&
Db.models.Gym
) || undefined,
) || BLOCKED,
}
: undefined,
s2cells: perms.s2cells ? { enabled: true, cells: true } : undefined,
s2cells: perms.s2cells ? { enabled: true, cells: true } : BLOCKED,
scanAreas: perms.scanAreas
? { filterByAreas: true, enabled: true }
: undefined,
weather: perms.weather && Db.models.Weather ? { enabled: true } : undefined,
weather: perms.weather && Db.models.Weather ? { enabled: true } : BLOCKED,
admin:
perms.spawnpoints || perms.scanCells || perms.devices
? {
spawnpoints:
!!(perms.spawnpoints && Db.models.Spawnpoint) || undefined,
scanCells: !!(perms.scanCells && Db.models.ScanCell) || undefined,
devices: !!(perms.devices && Db.models.Device) || undefined,
!!(perms.spawnpoints && Db.models.Spawnpoint) || BLOCKED,
scanCells: !!(perms.scanCells && Db.models.ScanCell) || BLOCKED,
devices: !!(perms.devices && Db.models.Device) || BLOCKED,
}
: undefined,
: BLOCKED,
settings: true,
}

Expand Down

0 comments on commit ec40756

Please sign in to comment.