mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-10 22:43:29 +00:00
fix: reset loading state when prompt save fails
When onSubmit throws an error (e.g. network failure), the loading flag was left as true, permanently disabling the Save button and showing an infinite spinner with no user feedback. Wrap the onSubmit call in try/catch so loading is always reset to false and an error toast is shown to the user on failure.
This commit is contained in:
parent
9bd84258d0
commit
bd71938b71
1 changed files with 22 additions and 17 deletions
|
|
@ -82,23 +82,28 @@
|
|||
loading = true;
|
||||
|
||||
if (validateCommandString(command)) {
|
||||
await onSubmit({
|
||||
id: prompt?.id,
|
||||
name,
|
||||
command,
|
||||
content,
|
||||
tags: tags.map((tag) => tag.name),
|
||||
access_grants: accessGrants,
|
||||
commit_message: commitMessage || undefined,
|
||||
is_production: isProduction
|
||||
});
|
||||
showEditModal = false;
|
||||
commitMessage = '';
|
||||
isProduction = true;
|
||||
await loadHistory(true); // Reset and reload
|
||||
// Select the newest version after saving
|
||||
if (history.length > 0) {
|
||||
selectedHistoryEntry = history[0];
|
||||
try {
|
||||
await onSubmit({
|
||||
id: prompt?.id,
|
||||
name,
|
||||
command,
|
||||
content,
|
||||
tags: tags.map((tag) => tag.name),
|
||||
access_grants: accessGrants,
|
||||
commit_message: commitMessage || undefined,
|
||||
is_production: isProduction
|
||||
});
|
||||
showEditModal = false;
|
||||
commitMessage = '';
|
||||
isProduction = true;
|
||||
await loadHistory(true); // Reset and reload
|
||||
// Select the newest version after saving
|
||||
if (history.length > 0) {
|
||||
selectedHistoryEntry = history[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to save prompt:', e);
|
||||
toast.error($i18n.t('Failed to save prompt. Please try again.'));
|
||||
}
|
||||
} else {
|
||||
toast.error(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue