diff options
| -rw-r--r-- | web/static/js/app.js | 25 | ||||
| -rw-r--r-- | web/templates/index.html | 9 |
2 files changed, 25 insertions, 9 deletions
diff --git a/web/static/js/app.js b/web/static/js/app.js index b68b12a..a930b1f 100644 --- a/web/static/js/app.js +++ b/web/static/js/app.js @@ -91,15 +91,20 @@ async function refreshData() { `; try { - // Refresh current tab - const response = await fetch(`/tabs/refresh?tab=${currentTab}`, { + // Force API refresh (updates cache) + const refreshResponse = await fetch('/api/refresh', { method: 'POST' }); - if (!response.ok) throw new Error('Refresh failed'); + if (!refreshResponse.ok) throw new Error('Refresh failed'); + + // Reload current tab from cache + const tabResponse = await fetch(`/tabs/${currentTab}`); + + if (!tabResponse.ok) throw new Error('Tab reload failed'); // Get HTML response and update tab content - const html = await response.text(); + const html = await tabResponse.text(); document.getElementById('tab-content').innerHTML = html; // Update timestamp @@ -138,12 +143,18 @@ async function autoRefresh() { console.log(`Auto-refreshing ${currentTab} tab...`); try { - const response = await fetch(`/tabs/refresh?tab=${currentTab}`, { + // Force API refresh (updates cache) + const refreshResponse = await fetch('/api/refresh', { method: 'POST' }); - if (response.ok) { - const html = await response.text(); + if (!refreshResponse.ok) throw new Error('Refresh failed'); + + // Reload current tab from cache + const tabResponse = await fetch(`/tabs/${currentTab}`); + + if (tabResponse.ok) { + const html = await tabResponse.text(); document.getElementById('tab-content').innerHTML = html; updateLastUpdatedTime(); console.log('Auto-refresh successful'); diff --git a/web/templates/index.html b/web/templates/index.html index b544ec3..b545a6e 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -61,8 +61,13 @@ </div> <!-- Tab Content --> - <div id="tab-content"> - {{template "tasks-tab" .}} + <div id="tab-content" + hx-get="/tabs/tasks" + hx-trigger="load" + hx-swap="innerHTML"> + <div class="text-center py-8"> + <div class="inline-block animate-pulse text-gray-600">Loading...</div> + </div> </div> </div> |
