re-swap table after refresh for consistent in-place updates
This commit was merged in pull request #9.
This commit is contained in:
@@ -135,17 +135,21 @@ async function clearCache() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refreshes both the current rating and the prediction in one click.
|
// Refreshes both the current rating and the prediction in one click, then
|
||||||
// The single refresh button in the actions cell is wired to this wrapper
|
// re-swaps the table so every derived value (deltas, pills, sparkline) reflects
|
||||||
// (design has only one icon; we used to have two separate refresh buttons).
|
// the new state. Cheaper than fine-grained DOM updates and guaranteed consistent
|
||||||
|
// because the server renders the truth.
|
||||||
async function refreshPlayerData(pdgaNumber) {
|
async function refreshPlayerData(pdgaNumber) {
|
||||||
const icon = document.querySelector(`#row-${pdgaNumber} .cell-actions .refresh-icon`);
|
const icon = document.querySelector(`#row-${pdgaNumber} .cell-actions .refresh-icon`);
|
||||||
if (icon) icon.classList.add('spinning');
|
if (icon) icon.classList.add('spinning');
|
||||||
try {
|
try {
|
||||||
await Promise.allSettled([
|
await Promise.allSettled([
|
||||||
refreshPlayer(pdgaNumber),
|
fetch(`/api/refresh-player/${pdgaNumber}`, { method: 'POST' }),
|
||||||
refreshRoundHistory(pdgaNumber)
|
fetch(`/api/refresh-round-history/${pdgaNumber}`, { method: 'POST' })
|
||||||
]);
|
]);
|
||||||
|
htmx.ajax('GET', '/partials/ratings-table', { target: '#ratings-table', swap: 'innerHTML' });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error refreshing player data:', error);
|
||||||
} finally {
|
} finally {
|
||||||
if (icon) icon.classList.remove('spinning');
|
if (icon) icon.classList.remove('spinning');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user