fdsfsda
This commit is contained in:
+11
-4
@@ -1229,10 +1229,17 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Sync count to server truth (handles race conditions)
|
||||
if (data.success && favBtn && data.favs) {
|
||||
const countEl = favBtn.querySelector('.scroll-btn-count');
|
||||
if (countEl) countEl.textContent = data.favs.length;
|
||||
// Sync state and count to server truth (handles race conditions)
|
||||
if (data.success && favBtn) {
|
||||
if (data.favorited !== undefined) {
|
||||
favBtn.classList.toggle('faved', data.favorited);
|
||||
const icon = favBtn.querySelector('i');
|
||||
if (icon) icon.className = (data.favorited ? 'fa-solid' : 'fa-regular') + ' fa-heart';
|
||||
}
|
||||
if (data.favs) {
|
||||
const countEl = favBtn.querySelector('.scroll-btn-count');
|
||||
if (countEl) countEl.textContent = data.favs.length;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Rollback optimistic update on error
|
||||
|
||||
Reference in New Issue
Block a user