Load cities on gallery init

This commit is contained in:
vishnukvmd 2024-01-23 13:36:46 +05:30
parent 877499be9b
commit 49ec70f5cf
3 changed files with 27 additions and 0 deletions

View file

@ -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);

View 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();

View file

@ -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';