fix notifications

This commit is contained in:
Andras Bacsai
2024-11-05 11:33:33 +01:00
parent 5ce6c3ded1
commit 9995663f01
6 changed files with 50 additions and 22 deletions
+20 -7
View File
@@ -41,7 +41,7 @@ class Discord extends Component
$this->team = auth()->user()->currentTeam();
$this->syncData();
} catch (\Throwable $e) {
handleError($e, $this);
return handleError($e, $this);
}
}
@@ -57,11 +57,8 @@ class Discord extends Component
$this->team->discord_notifications_database_backups = $this->discordNotificationsDatabaseBackups;
$this->team->discord_notifications_scheduled_tasks = $this->discordNotificationsScheduledTasks;
$this->team->discord_notifications_server_disk_usage = $this->discordNotificationsServerDiskUsage;
try {
$this->saveModel();
} catch (\Throwable $e) {
return handleError($e, $this);
}
$this->team->save();
refreshSession();
} else {
$this->discordEnabled = $this->team->discord_enabled;
$this->discordWebhookUrl = $this->team->discord_webhook_url;
@@ -74,6 +71,22 @@ class Discord extends Component
}
}
public function instantSaveDiscordEnabled()
{
try {
$this->validate([
'discordWebhookUrl' => 'required',
], [
'discordWebhookUrl.required' => 'Discord Webhook URL is required.',
]);
$this->saveModel();
} catch (\Throwable $e) {
$this->discordEnabled = false;
return handleError($e, $this);
}
}
public function instantSave()
{
try {
@@ -96,7 +109,7 @@ class Discord extends Component
public function saveModel()
{
$this->team->save();
$this->syncData(true);
refreshSession();
$this->dispatch('success', 'Settings saved.');
}