fix(core): improve instantSave logic and error handling
This commit is contained in:
parent
798aab6955
commit
8a11de9b1a
1 changed files with 7 additions and 8 deletions
|
|
@ -114,19 +114,24 @@ public function submit()
|
|||
public function instantSave(string $type)
|
||||
{
|
||||
try {
|
||||
$currentSmtpEnabled = $this->settings->smtp_enabled;
|
||||
$currentResendEnabled = $this->settings->resend_enabled;
|
||||
$this->resetErrorBag();
|
||||
|
||||
if ($type === 'SMTP') {
|
||||
$this->submitSmtp();
|
||||
$this->resendEnabled = $this->settings->resend_enabled = false;
|
||||
} elseif ($type === 'Resend') {
|
||||
$this->submitResend();
|
||||
$this->smtpEnabled = $this->settings->smtp_enabled = false;
|
||||
}
|
||||
$this->settings->save();
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
if ($type === 'SMTP') {
|
||||
$this->smtpEnabled = false;
|
||||
$this->smtpEnabled = $currentSmtpEnabled;
|
||||
} elseif ($type === 'Resend') {
|
||||
$this->resendEnabled = false;
|
||||
$this->resendEnabled = $currentResendEnabled;
|
||||
}
|
||||
|
||||
return handleError($e, $this);
|
||||
|
|
@ -156,9 +161,6 @@ public function submitSmtp()
|
|||
'smtpEncryption.required' => 'Encryption type is required.',
|
||||
]);
|
||||
|
||||
$this->resendEnabled = false;
|
||||
$this->settings->resend_enabled = false;
|
||||
|
||||
$this->settings->smtp_enabled = $this->smtpEnabled;
|
||||
$this->settings->smtp_host = $this->smtpHost;
|
||||
$this->settings->smtp_port = $this->smtpPort;
|
||||
|
|
@ -194,9 +196,6 @@ public function submitResend()
|
|||
'smtpFromName.required' => 'From Name is required.',
|
||||
]);
|
||||
|
||||
$this->smtpEnabled = false;
|
||||
$this->settings->smtp_enabled = false;
|
||||
|
||||
$this->settings->resend_enabled = $this->resendEnabled;
|
||||
$this->settings->resend_api_key = $this->resendApiKey;
|
||||
$this->settings->smtp_from_address = $this->smtpFromAddress;
|
||||
|
|
|
|||
Loading…
Reference in a new issue