Skip to content

Commit

Permalink
fix: added timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuscs committed Jun 2, 2024
1 parent 8e473b1 commit e6af1da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/inertia-flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

// Defaults for the notification
'defaults' => [
'timeout' => 5000,
'namespace' => 'flashNotifications',
'read_route' => 'notification.read',
'type' => Flavorly\InertiaFlash\Notification\Enums\NotificationTypeEnum::Flash,
Expand Down
1 change: 1 addition & 0 deletions src/Helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function flash(): FlashNotification
{
return (new FlashNotification())
->viaInertia()
->timeout()
->success();
}
}
11 changes: 11 additions & 0 deletions src/Notification/FlashNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ public function unsafe(): static
return $this;
}

/**
* Defines the timeout for the notification
*/
public function timeout(?int $timeout = null): static
{
// @phpstan-ignore-next-line
$this->timeout = $timeout ?? intval(config('inertia-flash.notifications.defaults.timeout', 5000));

return $this;
}

/**
* Returns the notification as a json
*/
Expand Down

0 comments on commit e6af1da

Please sign in to comment.