From 4b2ffb456fa6d73d42da0ac400e49a018e19984c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 15 Sep 2023 17:30:26 +0200 Subject: [PATCH] fix: team error --- app/Http/Livewire/Notifications/DiscordSettings.php | 1 + app/Http/Livewire/Notifications/EmailSettings.php | 5 +++++ app/Http/Livewire/Notifications/TelegramSettings.php | 1 + app/Http/Livewire/Team/Form.php | 1 + app/Models/Team.php | 6 +++--- bootstrap/helpers/shared.php | 2 +- versions.json | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/Notifications/DiscordSettings.php b/app/Http/Livewire/Notifications/DiscordSettings.php index 800addc24..f39ea9175 100644 --- a/app/Http/Livewire/Notifications/DiscordSettings.php +++ b/app/Http/Livewire/Notifications/DiscordSettings.php @@ -46,6 +46,7 @@ class DiscordSettings extends Component public function saveModel() { $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved.'); } diff --git a/app/Http/Livewire/Notifications/EmailSettings.php b/app/Http/Livewire/Notifications/EmailSettings.php index 33283d16b..68c0b931b 100644 --- a/app/Http/Livewire/Notifications/EmailSettings.php +++ b/app/Http/Livewire/Notifications/EmailSettings.php @@ -62,6 +62,7 @@ class EmailSettings extends Component 'team.smtp_from_name' => 'required', ]); $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved successfully.'); } catch (\Throwable $e) { return handleError($e, $this); @@ -81,6 +82,7 @@ class EmailSettings extends Component $this->team->smtp_enabled = false; $this->team->resend_enabled = false; $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved successfully.'); } catch (\Throwable $e) { return handleError($e, $this); @@ -110,6 +112,7 @@ class EmailSettings extends Component public function saveModel() { $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved.'); } public function submit() @@ -127,6 +130,7 @@ class EmailSettings extends Component 'team.smtp_timeout' => 'nullable', ]); $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved successfully.'); } catch (\Throwable $e) { $this->team->smtp_enabled = false; @@ -143,6 +147,7 @@ class EmailSettings extends Component 'team.resend_api_key' => 'required' ]); $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved successfully.'); } catch (\Throwable $e) { $this->team->resend_enabled = false; diff --git a/app/Http/Livewire/Notifications/TelegramSettings.php b/app/Http/Livewire/Notifications/TelegramSettings.php index b0313e1fb..1f4200076 100644 --- a/app/Http/Livewire/Notifications/TelegramSettings.php +++ b/app/Http/Livewire/Notifications/TelegramSettings.php @@ -52,6 +52,7 @@ class TelegramSettings extends Component public function saveModel() { $this->team->save(); + refreshSession(); $this->emit('success', 'Settings saved.'); } diff --git a/app/Http/Livewire/Team/Form.php b/app/Http/Livewire/Team/Form.php index ba17140c4..005a03432 100644 --- a/app/Http/Livewire/Team/Form.php +++ b/app/Http/Livewire/Team/Form.php @@ -27,6 +27,7 @@ class Form extends Component $this->validate(); try { $this->team->save(); + refreshSession(); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Models/Team.php b/app/Models/Team.php index e090796d5..6ae949d08 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -21,9 +21,9 @@ class Team extends Model implements SendsDiscord, SendsEmail protected static function booted() { - static::saved(function () { - refreshSession(); - }); + // static::saved(function () { + // refreshSession(); + // }); } public function routeNotificationForDiscord() diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 44e5d48bc..1b0c75faa 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -62,7 +62,7 @@ function showBoarding(): bool function refreshSession(?Team $team = null): void { if (!$team) { - if (auth()->user()->currentTeam()) { + if (auth()->user()?->currentTeam()) { $team = Team::find(auth()->user()->currentTeam()->id); } else { $team = User::find(auth()->user()->id)->teams->first(); diff --git a/versions.json b/versions.json index 3db6ccf65..16e56a1e9 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.38" + "version": "4.0.0-beta.33" } } }