ui: make notifications separate view

fix: popup if no notifications are set
This commit is contained in:
Andras Bacsai
2024-03-07 12:58:04 +01:00
parent bbfbd4a105
commit 129a644781
9 changed files with 108 additions and 14 deletions

View File

@@ -17,10 +17,14 @@ class LayoutPopups extends Component
{
$this->dispatch('success', 'Realtime events configured!');
}
public function disable()
public function disableSponsorship()
{
auth()->user()->update(['is_notification_sponsorship_enabled' => false]);
}
public function disableNotifications()
{
auth()->user()->update(['is_notification_notifications_enabled' => false]);
}
public function render()
{
return view('livewire.layout-popups');

View File

@@ -48,13 +48,15 @@ class Team extends Model implements SendsDiscord, SendsEmail
}
return explode(',', $recipients);
}
static public function serverLimitReached() {
static public function serverLimitReached()
{
$serverLimit = Team::serverLimit();
$team = currentTeam();
$servers = $team->servers->count();
return $servers >= $serverLimit;
}
public function serverOverflow() {
public function serverOverflow()
{
if ($this->serverLimit() < $this->servers->count()) {
return true;
}
@@ -170,4 +172,17 @@ class Team extends Model implements SendsDiscord, SendsEmail
]);
}
}
public function isAnyNotificationEnabled()
{
if (isCloud()) {
return true;
}
if (!data_get(auth()->user(), 'is_notification_notifications_enabled')) {
return true;
}
if ($this->smtp_enabled || $this->resend_enabled || $this->discord_enabled || $this->telegram_enabled || $this->use_instance_email_settings) {
return true;
}
return false;
}
}