feat(user): add changelog read tracking and unread count method

This commit is contained in:
Andras Bacsai
2025-08-07 21:57:00 +02:00
parent e8892b3d29
commit 0e7cc988a6
10 changed files with 887 additions and 110 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Livewire;
use App\Services\ChangelogService;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
class SettingsDropdown extends Component
{
public $showWhatsNewModal = false;
public function getUnreadCountProperty()
{
return Auth::user()->getUnreadChangelogCount();
}
public function getEntriesProperty()
{
$user = Auth::user();
return app(ChangelogService::class)->getEntriesForUser($user);
}
public function openWhatsNewModal()
{
$this->showWhatsNewModal = true;
}
public function closeWhatsNewModal()
{
$this->showWhatsNewModal = false;
}
public function markAsRead($identifier)
{
app(ChangelogService::class)->markAsReadForUser($identifier, Auth::user());
}
public function markAllAsRead()
{
app(ChangelogService::class)->markAllAsReadForUser(Auth::user());
}
public function render()
{
return view('livewire.settings-dropdown', [
'entries' => $this->entries,
'unreadCount' => $this->unreadCount,
]);
}
}