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:
parent
28cb561c04
commit
ac14a32723
1 changed files with 7 additions and 7 deletions
|
|
@ -99,10 +99,9 @@ public function submit()
|
|||
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 @@ private function handleBulkSubmit()
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue