Skip to content

Commit

Permalink
cleanup testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Nov 27, 2023
1 parent e715352 commit b1561de
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/types/lib/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export interface Config<Client extends boolean = false>
customizable: string[]
styles: ExampleConfig['icons']['styles'][number][]
defaultIcons: Record<string, string>
} & BaseConfig['icons']
} & Omit<BaseConfig['icons'], 'customizable' | 'styles' | 'defaultIcons'>
manualAreas: ExampleConfig['manualAreas'][number][]
}

Expand Down
31 changes: 31 additions & 0 deletions packages/types/lib/general.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type RMGeoJSON = {
}

import masterfile = require('packages/masterfile/lib/data/masterfile.json')
import { Config } from './config'

export type Masterfile = typeof masterfile

Expand Down Expand Up @@ -68,3 +69,33 @@ export interface Bounds {
minLon: number
maxLon: number
}

export type ImageExt = 'jpg' | 'jpeg' | 'png' | 'gif' | 'webp'
export type UiconImage = `${string}.${ImageExt}`
export interface UICONS {
device: UiconImage[]
gym: UiconImage[]
invasion: UiconImage[]
misc: UiconImage[]
nest: UiconImage[]
pokemon: UiconImage[]
pokestop: UiconImage[]
raid: {
egg: UiconImage[]
}
reward: {
[
key: Masterfile['questRewardTypes'][keyof Masterfile['questRewardTypes']]
]: UiconImage[]
}
spawnpoint: UiconImage[]
team: UiconImage[]
type: UiconImage[]
weather: UiconImage[]
}

export type UIconsClient = Config['icons']['styles'][number] & { data: UICONS }

export type FullClientIcons = Omit<Config['icons'], 'styles'> & {
styles: (Config['icons']['styles'][number] & { data: UICONS })[]
}
16 changes: 7 additions & 9 deletions src/hooks/useRefresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ export default function useRefresh() {
const existing = useStatic.getState().Icons
const Icons = existing ?? new UIcons(icons, masterfile.questRewardTypes)

if (!existing) {
Icons.build(icons.styles)
if (icons.defaultIcons) {
Icons.setSelection(icons.defaultIcons)
}
if (Icons.checkValid(userIcons)) {
Icons.setSelection(userIcons)
}
useStore.setState({ icons: Icons.selection })
Icons.build(icons.styles)
if (icons.defaultIcons && !existing) {
Icons.setSelection(icons.defaultIcons)
}
if (Icons.checkValid(userIcons)) {
Icons.setSelection(userIcons)
}
useStore.setState({ icons: Icons.selection })
if (masterfile) {
localStorage.setItem(
'questRewardTypes',
Expand Down
Loading

0 comments on commit b1561de

Please sign in to comment.