mirror of
https://github.com/basicswap/basicswap.git
synced 2026-04-08 18:37:23 +02:00
Hide refresh button for completed swaps.
This commit is contained in:
@@ -250,21 +250,23 @@ const BidPage = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setupAutoRefresh: function() {
|
setupAutoRefresh: function() {
|
||||||
if (!this.isActiveState()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const refreshBtn = document.getElementById('refresh');
|
const refreshBtn = document.getElementById('refresh');
|
||||||
if (!refreshBtn) return;
|
if (!refreshBtn) return;
|
||||||
|
|
||||||
|
if (!this.isActiveState()) {
|
||||||
|
refreshBtn.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const originalSpan = refreshBtn.querySelector('span');
|
const originalSpan = refreshBtn.querySelector('span');
|
||||||
if (!originalSpan) return;
|
if (!originalSpan) return;
|
||||||
|
|
||||||
let countdown = this.AUTO_REFRESH_SECONDS;
|
let countdown = this.AUTO_REFRESH_SECONDS;
|
||||||
let isRefreshing = false;
|
let isRefreshing = false;
|
||||||
|
let isPersistentlyPaused = false;
|
||||||
|
|
||||||
const updateCountdown = () => {
|
const updateCountdown = () => {
|
||||||
if (this.refreshPaused || isRefreshing) return;
|
if (this.refreshPaused || isPersistentlyPaused || isRefreshing) return;
|
||||||
|
|
||||||
originalSpan.textContent = `Auto-refresh in ${countdown}s`;
|
originalSpan.textContent = `Auto-refresh in ${countdown}s`;
|
||||||
countdown--;
|
countdown--;
|
||||||
@@ -282,22 +284,41 @@ const BidPage = {
|
|||||||
updateCountdown();
|
updateCountdown();
|
||||||
this.autoRefreshInterval = setInterval(updateCountdown, 1000);
|
this.autoRefreshInterval = setInterval(updateCountdown, 1000);
|
||||||
|
|
||||||
|
refreshBtn.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (isPersistentlyPaused) {
|
||||||
|
window.location.href = window.location.pathname + window.location.search;
|
||||||
|
} else {
|
||||||
|
isPersistentlyPaused = true;
|
||||||
|
if (this.autoRefreshInterval) {
|
||||||
|
clearInterval(this.autoRefreshInterval);
|
||||||
|
this.autoRefreshInterval = null;
|
||||||
|
}
|
||||||
|
originalSpan.textContent = 'Paused (click to refresh)';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
refreshBtn.addEventListener('mouseenter', () => {
|
refreshBtn.addEventListener('mouseenter', () => {
|
||||||
|
if (!isPersistentlyPaused) {
|
||||||
this.refreshPaused = true;
|
this.refreshPaused = true;
|
||||||
if (this.autoRefreshInterval) {
|
if (this.autoRefreshInterval) {
|
||||||
clearInterval(this.autoRefreshInterval);
|
clearInterval(this.autoRefreshInterval);
|
||||||
this.autoRefreshInterval = null;
|
this.autoRefreshInterval = null;
|
||||||
}
|
}
|
||||||
originalSpan.textContent = 'Click to refresh (paused)';
|
originalSpan.textContent = 'Click to pause';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
refreshBtn.addEventListener('mouseleave', () => {
|
refreshBtn.addEventListener('mouseleave', () => {
|
||||||
|
if (!isPersistentlyPaused) {
|
||||||
this.refreshPaused = false;
|
this.refreshPaused = false;
|
||||||
countdown = this.AUTO_REFRESH_SECONDS;
|
countdown = this.AUTO_REFRESH_SECONDS;
|
||||||
if (!this.autoRefreshInterval) {
|
if (!this.autoRefreshInterval) {
|
||||||
updateCountdown();
|
updateCountdown();
|
||||||
this.autoRefreshInterval = setInterval(updateCountdown, 1000);
|
this.autoRefreshInterval = setInterval(updateCountdown, 1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user