Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Load cities on gallery init

vishnukvmd49ec70f5cf8a
diff --git a/apps/photos/src/pages/gallery/index.tsx b/apps/photos/src/pages/gallery/index.tsx
index e477367a58..82731dfdc9 100644
--- a/apps/photos/src/pages/gallery/index.tsx
+++ b/apps/photos/src/pages/gallery/index.tsx
@@ -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);
diff --git a/apps/photos/src/services/locationSearchService.ts b/apps/photos/src/services/locationSearchService.ts
new file mode 100644
index 0000000000..377c4efedf
--- /dev/null
+++ b/apps/photos/src/services/locationSearchService.ts
@@ -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();
diff --git a/packages/shared/constants/urls.ts b/packages/shared/constants/urls.ts
index 291704e98f..65d961ddd7 100644
--- a/packages/shared/constants/urls.ts
+++ b/packages/shared/constants/urls.ts
@@ -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';