Report failures where the operator can still see them
The 55 alert() calls carried the same suppression as the confirms, and go wrong in the worse direction: a silenced confirm makes a button do nothing, while a silenced alert lets the action run and says nothing about it failing. vvAlert returns a promise nobody has to await, so these converted by rename with no caller becoming async. The icon is inferred from the message rather than asked of fifty call sites, and an explicit type still wins.
This commit is contained in:
@@ -1917,7 +1917,7 @@ async function vvSaveScript() {
|
||||
const name = document.getElementById('vv-editor-name').value.trim();
|
||||
const content = document.getElementById('vv-editor-body').value;
|
||||
if (!name || !/^[a-zA-Z0-9_\-]+$/.test(name)) {
|
||||
alert('Name must be letters, numbers, _ or - only (no spaces, no .sh)');
|
||||
vvAlert('Name must be letters, numbers, _ or - only (no spaces, no .sh)');
|
||||
return;
|
||||
}
|
||||
if (!await vvConfirm('Save changes to "' + name + '.sh"?')) return;
|
||||
@@ -1926,7 +1926,7 @@ async function vvSaveScript() {
|
||||
btn.textContent = 'Saving…';
|
||||
vvPost('/plugins/varaverk/api/script.php', {name, content})
|
||||
.then(d => {
|
||||
if (!d.ok) { alert('Save failed: ' + (d.error ?? 'Unknown error')); btn.disabled = false; btn.textContent = 'Save Script'; return; }
|
||||
if (!d.ok) { vvAlert('Save failed: ' + (d.error ?? 'Unknown error')); btn.disabled = false; btn.textContent = 'Save Script'; return; }
|
||||
localStorage.setItem('vv-last-job', d.id);
|
||||
window.location.reload();
|
||||
})
|
||||
@@ -1942,7 +1942,7 @@ async function vvDeleteScript() {
|
||||
btn.textContent = 'Deleting…';
|
||||
vvPost('/plugins/varaverk/api/script.php', {action: 'delete', name})
|
||||
.then(d => {
|
||||
if (!d.ok) { alert('Delete failed: ' + (d.error ?? 'Unknown error')); btn.disabled = false; btn.textContent = '\u{1F5D1} Delete'; return; }
|
||||
if (!d.ok) { vvAlert('Delete failed: ' + (d.error ?? 'Unknown error')); btn.disabled = false; btn.textContent = '\u{1F5D1} Delete'; return; }
|
||||
localStorage.removeItem('vv-last-job');
|
||||
window.location.reload();
|
||||
})
|
||||
@@ -2119,16 +2119,16 @@ async function _vvImpDoImport() {
|
||||
vvPost('/plugins/varaverk/api/import_script.php', {action: 'import', path: _vvImpSelected})
|
||||
.then(d => {
|
||||
if (!d.ok) {
|
||||
alert('Import failed: ' + (d.error || 'Unknown error'));
|
||||
vvAlert('Import failed: ' + (d.error || 'Unknown error'));
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Import';
|
||||
return;
|
||||
}
|
||||
if (d.warning) alert(d.warning);
|
||||
if (d.warning) vvAlert(d.warning);
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(e => {
|
||||
alert('Import failed: ' + e);
|
||||
vvAlert('Import failed: ' + e);
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Import';
|
||||
});
|
||||
@@ -2270,7 +2270,7 @@ async function vvSaveConf() {
|
||||
setTimeout(() => { btn.textContent = 'Save Config'; }, 2500);
|
||||
} else {
|
||||
btn.textContent = 'Save Config';
|
||||
alert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
vvAlert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
}
|
||||
})
|
||||
.catch(() => { btn.disabled = false; btn.textContent = 'Save Config'; });
|
||||
@@ -3503,7 +3503,7 @@ async function vvSaveRawConf() {
|
||||
btn.disabled = false;
|
||||
if (!d.ok) {
|
||||
btn.textContent = 'Save Conf';
|
||||
alert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
vvAlert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4772,7 +4772,7 @@ async function _vvFolderDrop(e) {
|
||||
|
||||
if (!r.ok) {
|
||||
oldParent.appendChild(srcEl);
|
||||
alert('Failed to save folder assignment.');
|
||||
vvAlert('Failed to save folder assignment.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4921,12 +4921,12 @@ function vvNewFolder() {
|
||||
async function _vvDoCreateFolder(name, wrap) {
|
||||
if (!name) return;
|
||||
const folders = vvGetCurrentFolders();
|
||||
if (folders[name] !== undefined) { alert(`Folder "${name}" already exists.`); return; }
|
||||
if (folders[name] !== undefined) { vvAlert(`Folder "${name}" already exists.`); return; }
|
||||
folders[name] = [];
|
||||
const r = await vvPost('/plugins/varaverk/api/savefolders.php', {
|
||||
folders: JSON.stringify(folders)
|
||||
}).then(r => r.json()).catch(() => ({ ok: false }));
|
||||
if (!r.ok) { alert('Failed to create folder.'); return; }
|
||||
if (!r.ok) { vvAlert('Failed to create folder.'); return; }
|
||||
wrap.remove();
|
||||
// Add folder group to DOM
|
||||
const customChildren = document.getElementById('vv-custom-children');
|
||||
|
||||
Reference in New Issue
Block a user