Enhance modal toggle functionality and update service interaction

This commit is contained in:
Will Miao
2025-03-07 09:33:58 +08:00
parent 2e47b30ed5
commit a9b3131e64
3 changed files with 46 additions and 8 deletions

View File

@@ -31,9 +31,9 @@ export class UpdateService {
this.checkForUpdates();
// Set up event listener for update button
const updateToggle = document.querySelector('.update-toggle');
const updateToggle = document.getElementById('updateToggleBtn');
if (updateToggle) {
updateToggle.addEventListener('click', () => this.showUpdateModal());
updateToggle.addEventListener('click', () => this.toggleUpdateModal());
}
// Immediately update modal content with current values (even if from default)
@@ -165,14 +165,32 @@ export class UpdateService {
}
}
showUpdateModal() {
// Force a check for updates when showing the modal
toggleUpdateModal() {
const updateModal = modalManager.getModal('updateModal');
// If modal is already open, just close it
if (updateModal && updateModal.isOpen) {
modalManager.closeModal('updateModal');
return;
}
// Update the modal content immediately with current data
this.updateModalContent();
// Show the modal with current data
modalManager.showModal('updateModal');
// Then check for updates in the background
this.manualCheckForUpdates().then(() => {
// Show the modal after update check completes
modalManager.showModal('updateModal');
// Update the modal content again after the check completes
this.updateModalContent();
});
}
showUpdateModal() {
this.toggleUpdateModal();
}
async manualCheckForUpdates() {
this.lastCheckTime = 0; // Reset last check time to force check
await this.checkForUpdates();