fix(delete-modal): close modal after successful delete
The success path of handleConfirm() never reset the isSubmitting flag, so hide()'s early-return guard (line 209: 'if (isSubmitting) return') kept the modal visible after a successful delete — leaving the user looking at a stuck 'Deleting...' dialog while the card had already been removed by the WebSocket SERIES_DELETED event. Reset isSubmitting and the confirm button text before calling hide(), and capture currentKey into a local before hide() nulls it so the follow-up removeSeries() call receives the right key.
This commit is contained in:
@@ -300,6 +300,9 @@ AniWorld.DeleteModal = (function() {
|
||||
var result = await response.json();
|
||||
console.info('[DeleteModal] Delete succeeded:', result);
|
||||
|
||||
// Capture key before hide() nulls currentKey
|
||||
var deletedKey = currentKey;
|
||||
|
||||
// Show success message based on what was deleted
|
||||
var msgParts = [];
|
||||
if (result.deleted_from_database) msgParts.push('removed from database');
|
||||
@@ -311,11 +314,17 @@ AniWorld.DeleteModal = (function() {
|
||||
: 'Delete completed.';
|
||||
|
||||
AniWorld.UI.showToast(successMsg, result.success ? 'success' : 'warning');
|
||||
|
||||
// Close modal and reset submission state together — isSubmitting must
|
||||
// be cleared before hide(), otherwise hide() bails out (early return
|
||||
// on the !isSubmitting guard) and the modal stays visible.
|
||||
isSubmitting = false;
|
||||
if (confirmBtn) confirmBtn.textContent = 'Delete';
|
||||
hide();
|
||||
|
||||
// Remove the card from the grid directly
|
||||
if (AniWorld.SeriesManager && AniWorld.SeriesManager.removeSeries) {
|
||||
AniWorld.SeriesManager.removeSeries(currentKey);
|
||||
AniWorld.SeriesManager.removeSeries(deletedKey);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user