Skip to content

Commit

Permalink
remove dep from RouteStore
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Jun 3, 2024
1 parent 7b26e52 commit 6d54338
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ setApi(config.routingApi, config.geocodingApi, apiKey || '')

const initialCustomModelStr = url.searchParams.get('custom_model')
const queryStore = new QueryStore(getApi(), initialCustomModelStr)
const routeStore = new RouteStore(queryStore)
const routeStore = new RouteStore()

setStores({
settingsStore: new SettingsStore(),
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/SettingsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function SettingsToggle({ title, enabled, onClick }: { title: string; enabled: b
function SettingsCheckbox({ title, enabled, onClick }: { title: string; enabled: boolean; onClick: () => void }) {
return (
<div className={styles.settingsCheckbox} onClick={onClick}>
<input type="checkbox" checked={enabled} onChange={(ignore) => {}}></input>
<input type="checkbox" checked={enabled} onChange={ignore => {}}></input>
<label style={{ color: enabled ? '#5b616a' : 'gray' }}>{title}</label>
</div>
)
Expand Down
4 changes: 3 additions & 1 deletion src/sidebar/search/AddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ class Geocoder {

await this.timeout.wait()
try {
const options: Record<string, string> = bias ? { point: coordinateToText(bias), location_bias_scale: "0.5", zoom: "9" } : {}
const options: Record<string, string> = bias
? { point: coordinateToText(bias), location_bias_scale: '0.5', zoom: '9' }
: {}
const result = await this.api.geocode(query, provider, options)
const hits = Geocoder.filterDuplicates(result.hits)
if (currentId === this.requestId) this.onSuccess(query, provider, hits)
Expand Down
5 changes: 1 addition & 4 deletions src/stores/RouteStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ export default class RouteStore extends Store<RouteStoreState> {
}
}

private readonly queryStore: QueryStore

constructor(queryStore: QueryStore) {
constructor() {
super(RouteStore.getInitialState())
this.queryStore = queryStore
}

reduce(state: RouteStoreState, action: Action): RouteStoreState {
Expand Down
2 changes: 1 addition & 1 deletion test/stores/RouteStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('RouteStore', () => {
})

function createStore() {
const store = new RouteStore(new QueryStore(new DummyApi()))
const store = new RouteStore()
Dispatcher.register(store)
return store
}
Expand Down

0 comments on commit 6d54338

Please sign in to comment.