Skip to content

Commit f8acda2

Browse files
authored
Merge pull request #531 from WatWowMap/split-up-wayfarer
Split up Wayfarer
2 parents 47da9b9 + 09efcc1 commit f8acda2

File tree

9 files changed

+149
-92
lines changed

9 files changed

+149
-92
lines changed

public/base-locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@
547547
"quest_condition": "Quest Condition",
548548
"always_show_labels": "Always Show Labels",
549549
"scan_areas_options": "Scan Areas Options",
550+
"poi": "Points of Interest",
550551
"300m_range": "300m Range",
551552
"lure_range": "Lure Range"
552553
}

server/src/configs/custom-environment-variables.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,18 @@
876876
"enabled": {
877877
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_ENABLED",
878878
"__format": "boolean"
879+
},
880+
"rings": {
881+
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_RINGS",
882+
"__format": "boolean"
883+
},
884+
"s17Cells": {
885+
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_S17CELLS",
886+
"__format": "boolean"
887+
},
888+
"s14Cells": {
889+
"__name": "DEFAULT_FILTERS_SUBMISSION_CELLS_S14CELLS",
890+
"__format": "boolean"
879891
}
880892
},
881893
"weather": {

server/src/configs/default.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,10 @@
419419
"enabled": false
420420
},
421421
"submissionCells": {
422-
"enabled": false
422+
"enabled": false,
423+
"rings": true,
424+
"s17Cells": true,
425+
"s14Cells": true
423426
},
424427
"weather": {
425428
"enabled": true

server/src/graphql/resolvers.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,13 @@ module.exports = {
299299
return [
300300
{
301301
placementCells:
302-
args.zoom >= config.map.submissionZoom
302+
args.zoom >= config.map.submissionZoom &&
303+
args.filters.onlyS17Cells
303304
? Utility.getPlacementCells(args, pokestops, gyms)
304305
: [],
305-
typeCells: Utility.getTypeCells(args, pokestops, gyms),
306+
typeCells: args.filters.onlyS14Cells
307+
? Utility.getTypeCells(args, pokestops, gyms)
308+
: [],
306309
},
307310
]
308311
}

server/src/services/defaultFilters/buildDefaultFilters.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ module.exports = function buildDefault(perms, available) {
106106
submissionCells: perms.submissionCells
107107
? {
108108
enabled: defaultFilters.submissionCells.enabled,
109+
rings: defaultFilters.submissionCells.rings,
110+
s17Cells: defaultFilters.submissionCells.s17Cells,
111+
s14Cells: defaultFilters.submissionCells.s14Cells,
109112
filter: { global: new GenericFilter() },
110113
}
111114
: undefined,

server/src/services/functions/getPlacementCells.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ module.exports = function getPlacementCells(bounds, pokestops, gyms) {
4646
cell.blocked = true
4747
}
4848
}
49-
const rings = allCoords.map((poi) => new Ring(poi.id, poi.lat, poi.lon))
49+
const rings = bounds.filters.onlyRings
50+
? allCoords.map((poi) => new Ring(poi.id, poi.lat, poi.lon))
51+
: []
5052

5153
return {
5254
cells: Object.values(indexedCells),

server/src/services/ui/clientOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function clientOptions(perms) {
1717
clustering: { type: 'bool', perm: ['gyms', 'raids'] },
1818
raidTimers: { type: 'bool', perm: ['raids'] },
1919
interactionRanges: { type: 'bool', perm: ['gyms', 'raids'] },
20-
"300mRange": { type: 'bool', perm: ['raids'] },
20+
'300mRange': { type: 'bool', perm: ['raids'] },
2121
showExBadge: { type: 'bool', perm: ['gyms'] },
2222
showArBadge: { type: 'bool', perm: ['gyms'] },
2323
raidLevelBadges: { type: 'bool', perm: ['raids'] },

server/src/services/ui/primary.js

Lines changed: 84 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,98 @@
1-
/* eslint-disable no-restricted-syntax */
21
const {
32
api: {
43
pvp: { leagues },
54
},
65
defaultFilters: {
7-
nests: { avgSliderStep },
6+
nests: { avgSliderStep, avgFilter },
87
},
98
} = require('../config')
109

10+
const refSliders = {
11+
pokemon: {
12+
primary: [
13+
{
14+
name: 'iv',
15+
label: '%',
16+
min: 0,
17+
max: 100,
18+
perm: 'iv',
19+
color: 'secondary',
20+
},
21+
],
22+
secondary: [
23+
{
24+
name: 'level',
25+
label: '',
26+
min: 1,
27+
max: 35,
28+
perm: 'iv',
29+
},
30+
{
31+
name: 'atk_iv',
32+
label: '',
33+
min: 0,
34+
max: 15,
35+
perm: 'iv',
36+
},
37+
{
38+
name: 'def_iv',
39+
label: '',
40+
min: 0,
41+
max: 15,
42+
perm: 'iv',
43+
},
44+
{
45+
name: 'sta_iv',
46+
label: '',
47+
min: 0,
48+
max: 15,
49+
perm: 'iv',
50+
},
51+
],
52+
},
53+
nests: {
54+
secondary: [
55+
{
56+
name: 'avgFilter',
57+
i18nKey: 'spawns_per_hour',
58+
label: '',
59+
min: avgFilter[0],
60+
max: avgFilter[1],
61+
perm: 'nests',
62+
step: avgSliderStep,
63+
},
64+
],
65+
},
66+
}
67+
68+
leagues.forEach((league) =>
69+
refSliders.pokemon.primary.push({
70+
name: league.name,
71+
label: 'rank',
72+
min: league.minRank || 1,
73+
max: league.maxRank || 100,
74+
perm: 'pvp',
75+
color: 'primary',
76+
}),
77+
)
78+
79+
const ignoredKeys = [
80+
'enabled',
81+
'filter',
82+
'showQuestSet',
83+
'badge',
84+
'avgFilter',
85+
'raidTier',
86+
]
87+
1188
module.exports = function generateUi(filters, perms) {
1289
const ui = {}
13-
const ignoredKeys = [
14-
'enabled',
15-
'filter',
16-
'showQuestSet',
17-
'badge',
18-
'avgFilter',
19-
'raidTier',
20-
]
2190

2291
// builds the initial categories
23-
for (const [key, value] of Object.entries(filters)) {
92+
Object.entries(filters).forEach(([key, value]) => {
2493
let sliders
2594
if (value) {
2695
switch (key) {
27-
case 'nests':
28-
ui[key] = {}
29-
sliders = {
30-
secondary: [
31-
{
32-
name: 'avgFilter',
33-
i18nKey: 'spawns_per_hour',
34-
label: '',
35-
min: filters.nests.avgFilter[0],
36-
max: filters.nests.avgFilter[1],
37-
perm: 'nests',
38-
step: avgSliderStep,
39-
},
40-
],
41-
}
42-
break
43-
case 'pokemon':
44-
ui[key] = {}
45-
sliders = {
46-
primary: [
47-
{
48-
name: 'iv',
49-
label: '%',
50-
min: 0,
51-
max: 100,
52-
perm: 'iv',
53-
color: 'secondary',
54-
},
55-
],
56-
secondary: [
57-
{
58-
name: 'level',
59-
label: '',
60-
min: 1,
61-
max: 35,
62-
perm: 'iv',
63-
},
64-
{
65-
name: 'atk_iv',
66-
label: '',
67-
min: 0,
68-
max: 15,
69-
perm: 'iv',
70-
},
71-
{
72-
name: 'def_iv',
73-
label: '',
74-
min: 0,
75-
max: 15,
76-
perm: 'iv',
77-
},
78-
{
79-
name: 'sta_iv',
80-
label: '',
81-
min: 0,
82-
max: 15,
83-
perm: 'iv',
84-
},
85-
],
86-
}
87-
leagues.forEach((league) =>
88-
sliders.primary.push({
89-
name: league.name,
90-
label: 'rank',
91-
min: league.minRank || 1,
92-
max: league.maxRank || 100,
93-
perm: 'pvp',
94-
color: 'primary',
95-
}),
96-
)
97-
break
9896
case 'submissionCells':
9997
case 'portals':
10098
if (!ui.wayfarer) ui.wayfarer = {}
@@ -108,10 +106,11 @@ module.exports = function generateUi(filters, perms) {
108106
break
109107
default:
110108
ui[key] = {}
109+
sliders = refSliders[key]
111110
break
112111
}
113112
// builds each subcategory
114-
for (const [subKey, subValue] of Object.entries(value)) {
113+
Object.entries(value).forEach(([subKey, subValue]) => {
115114
if (
116115
(!ignoredKeys.includes(subKey) && subValue !== undefined) ||
117116
key === 'weather' ||
@@ -136,7 +135,7 @@ module.exports = function generateUi(filters, perms) {
136135
break
137136
}
138137
}
139-
}
138+
})
140139
// adds any sliders present
141140
if (sliders) {
142141
ui[key].sliders = sliders
@@ -150,7 +149,7 @@ module.exports = function generateUi(filters, perms) {
150149
})
151150
}
152151
}
153-
}
152+
})
154153

155154
// deletes any menus that do not have any items/perms
156155
Object.keys(ui).forEach((category) => {

src/components/layout/drawer/WithSubItems.jsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react'
1+
import React, { Fragment } from 'react'
22
import { Grid, Typography, Switch, Select, MenuItem } from '@material-ui/core'
3-
import { useTranslation } from 'react-i18next'
3+
import { Trans, useTranslation } from 'react-i18next'
44

55
import Utility from '@services/Utility'
66

@@ -148,6 +148,40 @@ export default function WithSubItems({
148148
</Grid>
149149
</>
150150
)}
151+
{category === 'wayfarer' && subItem === 'submissionCells' && (
152+
<>
153+
{['rings', 's14Cells', 's17Cells'].map((item, i) => (
154+
<Fragment key={item}>
155+
<Grid item xs={8}>
156+
<Typography>
157+
{i ? (
158+
<Trans i18nKey="s2_cell_level">
159+
{{ level: item.substring(1, 3) }}
160+
</Trans>
161+
) : (
162+
t('poi')
163+
)}
164+
</Typography>
165+
</Grid>
166+
<Grid item xs={4} style={{ textAlign: 'right' }}>
167+
<Switch
168+
checked={filters[subItem][item]}
169+
onChange={() => {
170+
setFilters({
171+
...filters,
172+
[subItem]: {
173+
...filters[subItem],
174+
[item]: !filters[subItem][item],
175+
},
176+
})
177+
}}
178+
disabled={!filters[subItem].enabled}
179+
/>
180+
</Grid>
181+
</Fragment>
182+
))}
183+
</>
184+
)}
151185
</>
152186
)
153187
}

0 commit comments

Comments
 (0)