Spaces:
Runtime error
Runtime error
Fix UI blocking in form page initialization by loading data async
Browse files- static/index.html +2 -2
- static/js/tree-track-app.js +14 -10
- static/map.html +2 -2
- static/sw.js +1 -1
- version.json +1 -1
static/index.html
CHANGED
|
@@ -947,7 +947,7 @@
|
|
| 947 |
// Force refresh if we detect cached version
|
| 948 |
(function() {
|
| 949 |
const currentVersion = '5.1.1';
|
| 950 |
-
const timestamp = '
|
| 951 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 952 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 953 |
|
|
@@ -1193,7 +1193,7 @@
|
|
| 1193 |
</div>
|
| 1194 |
</div>
|
| 1195 |
|
| 1196 |
-
<script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=
|
| 1197 |
|
| 1198 |
<script>
|
| 1199 |
// Idle-time prefetch of map assets to speed up first navigation
|
|
|
|
| 947 |
// Force refresh if we detect cached version
|
| 948 |
(function() {
|
| 949 |
const currentVersion = '5.1.1';
|
| 950 |
+
const timestamp = '1762282760'; // Cache-busting bump
|
| 951 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 952 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 953 |
|
|
|
|
| 1193 |
</div>
|
| 1194 |
</div>
|
| 1195 |
|
| 1196 |
+
<script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=1762282760"></script>
|
| 1197 |
|
| 1198 |
<script>
|
| 1199 |
// Idle-time prefetch of map assets to speed up first navigation
|
static/js/tree-track-app.js
CHANGED
|
@@ -32,16 +32,23 @@ export class TreeTrackApp {
|
|
| 32 |
return;
|
| 33 |
}
|
| 34 |
|
| 35 |
-
// Initialize
|
| 36 |
-
|
| 37 |
|
| 38 |
-
// Setup event listeners
|
| 39 |
this.setupEventListeners();
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
} catch (error) {
|
| 47 |
console.error('Error initializing TreeTrack app:', error);
|
|
@@ -50,10 +57,7 @@ export class TreeTrackApp {
|
|
| 50 |
}
|
| 51 |
|
| 52 |
async initializeManagers() {
|
| 53 |
-
// Initialize
|
| 54 |
-
this.uiManager.initialize();
|
| 55 |
-
|
| 56 |
-
// Initialize form components
|
| 57 |
await this.formManager.initialize();
|
| 58 |
|
| 59 |
// Initialize media handling
|
|
|
|
| 32 |
return;
|
| 33 |
}
|
| 34 |
|
| 35 |
+
// Initialize UI immediately for responsiveness
|
| 36 |
+
this.uiManager.initialize();
|
| 37 |
|
| 38 |
+
// Setup event listeners early so UI is interactive
|
| 39 |
this.setupEventListeners();
|
| 40 |
|
| 41 |
+
// Load data-dependent managers and initial data in background
|
| 42 |
+
// This prevents blocking the UI while fetching from API
|
| 43 |
+
this.initializeManagers().catch(error => {
|
| 44 |
+
console.error('Error initializing managers:', error);
|
| 45 |
+
this.uiManager.showMessage('Error loading form data: ' + error.message, 'error');
|
| 46 |
+
});
|
| 47 |
|
| 48 |
+
this.loadInitialData().catch(error => {
|
| 49 |
+
console.error('Error loading initial data:', error);
|
| 50 |
+
this.uiManager.showMessage('Error loading tree data: ' + error.message, 'error');
|
| 51 |
+
});
|
| 52 |
|
| 53 |
} catch (error) {
|
| 54 |
console.error('Error initializing TreeTrack app:', error);
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
async initializeManagers() {
|
| 60 |
+
// Initialize form components (loads options from API)
|
|
|
|
|
|
|
|
|
|
| 61 |
await this.formManager.initialize();
|
| 62 |
|
| 63 |
// Initialize media handling
|
static/map.html
CHANGED
|
@@ -968,7 +968,7 @@
|
|
| 968 |
// Force refresh if we detect cached version
|
| 969 |
(function() {
|
| 970 |
const currentVersion = '5.1.1';
|
| 971 |
-
const timestamp = '
|
| 972 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 973 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 974 |
|
|
@@ -1137,7 +1137,7 @@ const timestamp = '1762282516'; // Current timestamp for cache busting
|
|
| 1137 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 1138 |
<!-- Leaflet MarkerCluster JS for performance and grouping -->
|
| 1139 |
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
|
| 1140 |
-
<script src="/static/map.js?v=5.1.1&t=
|
| 1141 |
<script>
|
| 1142 |
console.log('🗺️ Map script loaded successfully');
|
| 1143 |
</script>
|
|
|
|
| 968 |
// Force refresh if we detect cached version
|
| 969 |
(function() {
|
| 970 |
const currentVersion = '5.1.1';
|
| 971 |
+
const timestamp = '1762282760'; // Current timestamp for cache busting
|
| 972 |
const lastVersion = sessionStorage.getItem('treetrack_version');
|
| 973 |
const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
|
| 974 |
|
|
|
|
| 1137 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 1138 |
<!-- Leaflet MarkerCluster JS for performance and grouping -->
|
| 1139 |
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
|
| 1140 |
+
<script src="/static/map.js?v=5.1.1&t=1762282760"></script>
|
| 1141 |
<script>
|
| 1142 |
console.log('🗺️ Map script loaded successfully');
|
| 1143 |
</script>
|
static/sw.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
// TreeTrack Service Worker - PWA and Offline Support
|
| 2 |
-
const VERSION =
|
| 3 |
const CACHE_NAME = `treetrack-v${VERSION}`;
|
| 4 |
const STATIC_CACHE = `static-v${VERSION}`;
|
| 5 |
const API_CACHE = `api-v${VERSION}`;
|
|
|
|
| 1 |
// TreeTrack Service Worker - PWA and Offline Support
|
| 2 |
+
const VERSION = 1762282760; // Cache busting bump - force clients to fetch new static assets and header image change
|
| 3 |
const CACHE_NAME = `treetrack-v${VERSION}`;
|
| 4 |
const STATIC_CACHE = `static-v${VERSION}`;
|
| 5 |
const API_CACHE = `api-v${VERSION}`;
|
version.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
"version": "5.1.1",
|
| 3 |
-
"timestamp":
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"version": "5.1.1",
|
| 3 |
+
"timestamp": 1762282760
|
| 4 |
}
|