mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Merge 652ebb956d into 9a4b4280be
This commit is contained in:
commit
9fda43cf92
2 changed files with 60 additions and 1 deletions
|
|
@ -11,6 +11,12 @@ class SettingsDropdown extends Component
|
||||||
{
|
{
|
||||||
public $showWhatsNewModal = false;
|
public $showWhatsNewModal = false;
|
||||||
|
|
||||||
|
public bool $shouldPollChangelog = false;
|
||||||
|
|
||||||
|
public bool $changelogFetchRequested = false;
|
||||||
|
|
||||||
|
public int $changelogPollAttempts = 0;
|
||||||
|
|
||||||
public function getUnreadCountProperty()
|
public function getUnreadCountProperty()
|
||||||
{
|
{
|
||||||
return Auth::user()->getUnreadChangelogCount();
|
return Auth::user()->getUnreadChangelogCount();
|
||||||
|
|
@ -31,6 +37,53 @@ class SettingsDropdown extends Component
|
||||||
public function openWhatsNewModal()
|
public function openWhatsNewModal()
|
||||||
{
|
{
|
||||||
$this->showWhatsNewModal = true;
|
$this->showWhatsNewModal = true;
|
||||||
|
|
||||||
|
$this->prefetchChangelog();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prefetchChangelog()
|
||||||
|
{
|
||||||
|
$entries = app(ChangelogService::class)->getEntriesForUser(Auth::user());
|
||||||
|
if ($entries->isEmpty()) {
|
||||||
|
if (! $this->changelogFetchRequested) {
|
||||||
|
$this->changelogFetchRequested = true;
|
||||||
|
$this->shouldPollChangelog = true;
|
||||||
|
$this->changelogPollAttempts = 0;
|
||||||
|
PullChangelog::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatch('changelog-entries', entries: $entries->values()->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refreshChangelog()
|
||||||
|
{
|
||||||
|
if (! $this->shouldPollChangelog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->changelogPollAttempts++;
|
||||||
|
if ($this->changelogPollAttempts > 10) {
|
||||||
|
$this->shouldPollChangelog = false;
|
||||||
|
$this->changelogFetchRequested = false;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entries = app(ChangelogService::class)->getEntriesForUser(Auth::user());
|
||||||
|
if ($entries->isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->shouldPollChangelog = false;
|
||||||
|
$this->changelogFetchRequested = false;
|
||||||
|
$this->changelogPollAttempts = 0;
|
||||||
|
$this->dispatch('changelog-entries', entries: $entries->values()->all());
|
||||||
|
|
||||||
|
cache()->forget('user_unread_changelog_count_'.Auth::id());
|
||||||
|
$this->dispatch('$refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function closeWhatsNewModal()
|
public function closeWhatsNewModal()
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@
|
||||||
this.mounted();
|
this.mounted();
|
||||||
// Load all entries when component initializes
|
// Load all entries when component initializes
|
||||||
this.allEntries = @js($entries->toArray());
|
this.allEntries = @js($entries->toArray());
|
||||||
|
window.addEventListener('changelog-entries', (event) => {
|
||||||
|
this.allEntries = event.detail.entries ?? [];
|
||||||
|
});
|
||||||
},
|
},
|
||||||
markEntryAsRead(tagName) {
|
markEntryAsRead(tagName) {
|
||||||
// Update the entry in our local Alpine data
|
// Update the entry in our local Alpine data
|
||||||
|
|
@ -103,7 +106,10 @@
|
||||||
return new Date(b.published_at) - new Date(a.published_at);
|
return new Date(b.published_at) - new Date(a.published_at);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}" @click.outside="dropdownOpen = false">
|
}" @click.outside="dropdownOpen = false" wire:init="prefetchChangelog">
|
||||||
|
@if ($shouldPollChangelog)
|
||||||
|
<span class="hidden" wire:poll.1s="refreshChangelog"></span>
|
||||||
|
@endif
|
||||||
<!-- Custom Dropdown without arrow -->
|
<!-- Custom Dropdown without arrow -->
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<button @click="dropdownOpen = !dropdownOpen"
|
<button @click="dropdownOpen = !dropdownOpen"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue