Load cities on gallery init
This commit is contained in:
parent
877499be9b
commit
49ec70f5cf
3 changed files with 27 additions and 0 deletions
|
@ -131,6 +131,7 @@ import { ClipService } from 'services/clipService';
|
|||
import isElectron from 'is-electron';
|
||||
import downloadManager from 'services/download';
|
||||
import { APPS } from '@ente/shared/apps/constants';
|
||||
import locationSearchService from 'services/locationSearchService';
|
||||
|
||||
export const DeadCenter = styled('div')`
|
||||
flex: 1;
|
||||
|
@ -341,6 +342,7 @@ export default function Gallery() {
|
|||
setIsFirstLoad(false);
|
||||
setJustSignedUp(false);
|
||||
setIsFirstFetch(false);
|
||||
locationSearchService.loadCities();
|
||||
syncInterval.current = setInterval(() => {
|
||||
syncWithRemote(false, true);
|
||||
}, SYNC_INTERVAL_IN_MICROSECONDS);
|
||||
|
|
23
apps/photos/src/services/locationSearchService.ts
Normal file
23
apps/photos/src/services/locationSearchService.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { CITIES_URL } from '@ente/shared/constants/urls';
|
||||
|
||||
interface City {
|
||||
city: string;
|
||||
country: string;
|
||||
lat: number;
|
||||
lng: number;
|
||||
}
|
||||
|
||||
class LocationSearchService {
|
||||
private cities: Array<City> = [];
|
||||
|
||||
loadCities() {
|
||||
fetch(CITIES_URL).then((response) => {
|
||||
response.json().then((data) => {
|
||||
this.cities = data;
|
||||
console.log(this.cities);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default new LocationSearchService();
|
|
@ -17,3 +17,5 @@ export const WEB_ROADMAP_URL = 'https://github.com/ente-io/photos-web/issues';
|
|||
|
||||
export const DESKTOP_ROADMAP_URL =
|
||||
'https://github.com/ente-io/photos-desktop/issues';
|
||||
|
||||
export const CITIES_URL = 'https://assets.ente.io/world_cities.json';
|
||||
|
|
Loading…
Add table
Reference in a new issue