mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-18 05:20:43 +00:00
fix: dispatch success message after transaction commits
Move the success dispatch outside the DB transaction closure to ensure it only fires after the transaction has successfully committed. Use reference variable to track changes across the closure boundary.
This commit is contained in:
@@ -99,10 +99,9 @@ class Show extends Component
|
||||
private function handleBulkSubmit()
|
||||
{
|
||||
$variables = parseEnvFormatToArray($this->variables);
|
||||
$changesMade = false;
|
||||
|
||||
DB::transaction(function () use ($variables) {
|
||||
$changesMade = false;
|
||||
|
||||
DB::transaction(function () use ($variables, &$changesMade) {
|
||||
// Delete removed variables
|
||||
$deletedCount = $this->deleteRemovedVariables($variables);
|
||||
if ($deletedCount > 0) {
|
||||
@@ -114,11 +113,12 @@ class Show extends Component
|
||||
if ($updatedCount > 0) {
|
||||
$changesMade = true;
|
||||
}
|
||||
|
||||
if ($changesMade) {
|
||||
$this->dispatch('success', 'Environment variables updated.');
|
||||
}
|
||||
});
|
||||
|
||||
// Only dispatch success after transaction has committed
|
||||
if ($changesMade) {
|
||||
$this->dispatch('success', 'Environment variables updated.');
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteRemovedVariables($variables)
|
||||
|
||||
Reference in New Issue
Block a user