update: users online block cache and appearance

Make sure the cache caches based on the group since the privacy setting for showing up here can be based on the group. Also show the data in columns to look a little nicer.
This commit is contained in:
Roardom
2023-08-01 10:50:00 +00:00
parent 9d2613e7b0
commit d6a0d647a6
2 changed files with 7 additions and 5 deletions
+4 -2
View File
@@ -59,7 +59,7 @@ class HomeController extends Controller
'user' => $user,
'personal_freeleech' => cache()->get('personal_freeleech:'.$user->id),
'users' => cache()->remember(
'online_users',
'online_users:by-group:'.auth()->user()->group_id,
$expiresAt,
fn () => User::with('group', 'privacy')
->withCount([
@@ -67,8 +67,10 @@ class HomeController extends Controller
$query->whereNotNull('torrent')->where('active', '1');
},
])
->where('last_action', '>', now()->subMinutes(5))
->where('last_action', '>', now()->subDays(19))
->orderByRaw('(select position from `groups` where `groups`.id = users.group_id), group_id, username')
->get()
->sortBy(fn ($user) => $user->hidden || ! $user->isVisible($user, 'other', 'show_online'))
),
'groups' => cache()->remember(
'user-groups',
+3 -3
View File
@@ -4,7 +4,7 @@
{{ __('blocks.users-online') }} ({{ $users->count() }})
</h2>
<div class="panel__body">
<ul style="display: flex; flex-wrap: wrap; column-gap: 1rem; list-style-type: none; padding: 0">
<ul style="column-width: 200px; column-gap: 1rem; list-style-type: none; padding: 0">
@foreach ($users as $user)
<li>
<x-user_tag :user="$user" :anon="$user->hidden || ! $user->isVisible($user, 'other', 'show_online')">
@@ -21,9 +21,9 @@
@endforeach
</ul>
<hr>
<ul style="display: flex; flex-wrap: wrap; column-gap: 1rem; list-style-type: none; padding: 0; justify-content: center">
<ul style="column-width: 200px; column-gap: 1rem; list-style-type: none; padding: 0;">
@foreach ($groups as $group)
<span class="user-tag" style="background-image: {{ $group->effect }};">
<span class="user-tag" style="padding: 4px 8px; display: block">
<a
class="user-tag__link {{ $group->icon }}"
href="{{ route('group', ['id' => $group->id]) }}"