Load all saved place into memory

Fixes launching the app with a place URL directly, and will be useful
for search etc. later.
This commit is contained in:
2026-01-22 17:23:50 +07:00
parent 86b85e9a0b
commit 6e87ef3573
4 changed files with 88 additions and 14 deletions

View File

@@ -16,6 +16,9 @@ export default class PlaceRoute extends Route {
return this.loadOsmPlace(osmId, type);
}
// Wait for storage sync before checking bookmarks
await this.waitForSync();
// 1. Try to find in local bookmarks
let bookmark = this.storage.findPlaceById(id);
@@ -29,6 +32,22 @@ export default class PlaceRoute extends Route {
return this.loadOsmPlace(id);
}
async waitForSync() {
if (this.storage.initialSyncDone) return;
console.log('Waiting for initial storage sync...');
const timeout = 5000;
const start = Date.now();
while (!this.storage.initialSyncDone) {
if (Date.now() - start > timeout) {
console.warn('Timed out waiting for initial sync');
break;
}
await new Promise((resolve) => setTimeout(resolve, 100));
}
}
afterModel(model) {
// Notify the Map UI to show the pin
if (model) {