Skip to content

Commit

Permalink
Refactor notifications to use named parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPunyapal committed Apr 7, 2024
1 parent f8a5c10 commit 7324bd3
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/Livewire/LinkSettings/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function update(Request $request): void
$user->update(['settings' => $validated]);

$this->dispatch('link-settings.updated');
$this->dispatch('notification.created', 'Link settings updated.');
$this->dispatch('notification.created', message: 'Link settings updated.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Links/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function store(Request $request): void
$this->url = '';

$this->dispatch('link.created');
$this->dispatch('notification.created', 'Link created.');
$this->dispatch('notification.created', message: 'Link created.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Links/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function destroy(int $linkId): void

$link->delete();

$this->dispatch('notification.created', 'Link deleted.');
$this->dispatch('notification.created', message: 'Link deleted.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Questions/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function store(Request $request): void
$this->anonymously = $user->prefers_anonymous_questions;

$this->dispatch('question.created');
$this->dispatch('notification.created', 'Question sent.');
$this->dispatch('notification.created', message: 'Question sent.');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/Livewire/Questions/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function update(): void

$this->answer = '';

$this->dispatch('notification.created', 'Question answered.');
$this->dispatch('notification.created', message: 'Question answered.');
$this->dispatch('question.updated');
}

Expand All @@ -61,7 +61,7 @@ public function report(): void
'is_reported' => true,
]);

$this->dispatch('notification.created', 'Question reported.');
$this->dispatch('notification.created', message: 'Question reported.');
$this->dispatch('question.reported');
}

Expand All @@ -70,7 +70,7 @@ public function report(): void
*/
public function ignore(): void
{
$this->dispatch('notification.created', 'Question ignored.');
$this->dispatch('notification.created', message: 'Question ignored.');

$this->dispatch('question.ignore', questionId: $this->questionId);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Livewire/Questions/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function ignore(): void
}

if ($this->inIndex) {
$this->dispatch('notification.created', 'Question ignored.');
$this->dispatch('notification.created', message: 'Question ignored.');

$this->dispatch('question.ignore', questionId: $this->questionId);

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Livewire/FlashMessages/ShowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

$component = Livewire::test(Show::class);

$component->dispatch('notification.created', 'Hello, world!');
$component->dispatch('notification.created', message: 'Hello, world!');

$component->assertSee('Hello, world!');
$component->assertDontSee('Goodbye, world!');

$component->dispatch('notification.created', 'Goodbye, world!');
$component->dispatch('notification.created', message: 'Goodbye, world!');

$component->assertDontSee('Hello, world!');
$component->assertSee('Goodbye, world!');
Expand All @@ -23,7 +23,7 @@
test('flushes flash message', function () {
$component = Livewire::test(Show::class);

$component->dispatch('notification.created', 'Hello, world!');
$component->dispatch('notification.created', message: 'Hello, world!');

$component->assertSee('Hello, world!');
$component->assertSee('Hello, world!');
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Livewire/LinkSettings/EditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$component->call('update');

$component->assertDispatched('link-settings.updated');
$component->assertDispatched('notification.created', 'Link settings updated.');
$component->assertDispatched('notification.created', message: 'Link settings updated.');

$user->refresh();

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Livewire/Links/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$component->call('store');

$component->assertDispatched('link.created');
$component->assertDispatched('notification.created', 'Link created.');
$component->assertDispatched('notification.created', message: 'Link created.');

$user->refresh();

Expand All @@ -43,7 +43,7 @@
$component->call('store');

$component->assertDispatched('link.created');
$component->assertDispatched('notification.created', 'Link created.');
$component->assertDispatched('notification.created', message: 'Link created.');

$user->refresh();

Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Livewire/Questions/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
$component->assertSet('content', '');
$component->assertSet('anonymously', true);

$component->assertDispatched('notification.created', 'Question sent.');
$component->assertDispatched('notification.created', message: 'Question sent.');
$component->assertDispatched('question.created');

$question = App\Models\Question::first();
Expand Down Expand Up @@ -187,7 +187,7 @@
$component->assertSet('content', '');
$component->assertSet('anonymously', false);

$component->assertDispatched('notification.created', 'Question sent.');
$component->assertDispatched('notification.created', message: 'Question sent.');
$component->assertDispatched('question.created');

$question = App\Models\Question::first();
Expand Down Expand Up @@ -217,7 +217,7 @@
$component->assertSet('content', '');
$component->assertSet('anonymously', true);

$component->assertDispatched('notification.created', 'Question sent.');
$component->assertDispatched('notification.created', message: 'Question sent.');
$component->assertDispatched('question.created');

$question = App\Models\Question::first();
Expand Down Expand Up @@ -248,7 +248,7 @@
$component->assertSet('content', '');
$component->assertSet('anonymously', false);

$component->assertDispatched('notification.created', 'Question sent.');
$component->assertDispatched('notification.created', message: 'Question sent.');
$component->assertDispatched('question.created');

$question = App\Models\Question::first();
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Livewire/Questions/EditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

$component->call('ignore');

$component->assertDispatched('notification.created', 'Question ignored.');
$component->assertDispatched('notification.created', message: 'Question ignored.');
$component->assertDispatched('question.ignore', questionId: $this->question->id);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Livewire/Questions/ShowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
]);

$component->call('ignore');
$component->assertDispatched('notification.created', 'Question ignored.');
$component->assertDispatched('notification.created', message: 'Question ignored.');
$component->assertDispatched('question.ignore');
});

Expand Down

0 comments on commit 7324bd3

Please sign in to comment.