Skip to content

Commit f07dcac

Browse files
committed
Hub: Lazy loading recent activity - optimize performance
1 parent 3ee8a32 commit f07dcac

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

src/Controller/HubController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1111
use Symfony\Component\HttpFoundation\Response;
1212
use Symfony\Component\Routing\Attribute\Route;
13-
use Symfony\Component\Security\Core\User\UserInterface;
14-
use Symfony\Component\Security\Http\Attribute\CurrentUser;
1513

1614
final class HubController extends AbstractController
1715
{
@@ -33,7 +31,7 @@ public function __construct(
3331
],
3432
name: 'hub',
3533
)]
36-
public function __invoke(#[CurrentUser] null|UserInterface $user): Response
34+
public function __invoke(): Response
3735
{
3836
$thisMonth = (int) date("m");
3937
$thisYear = (int) date("Y");

templates/components/RecentActivity.html.twig

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,48 @@
164164
<button class="mt-3 btn btn-outline-primary btn-sm" data-action="click->show-more-recent-activity#revealRows" data-show-more-recent-activity-target="button">{{ 'show_more'|trans }}</button>
165165
{% endif %}
166166
</div>
167+
168+
{% macro placeholder(props) %}
169+
<div class="table-responsive custom-table-wrapper mt-4">
170+
<table class="table table-striped custom-table table-hover mb-0 placeholder-glow">
171+
<tbody>
172+
{% set rowCount = props.showLimit > 0 ? props.showLimit : props.limit|default(5) %}
173+
{% for i in 1..rowCount %}
174+
<tr>
175+
<td class="text-center" style="width: 90px;">
176+
<div class="position-relative">
177+
<span class="rounded-2 d-inline-block" style="width: 80px; height: 58px; background: #e9ecef;"></span>
178+
</div>
179+
</td>
180+
181+
<td class="d-none d-sm-table-cell">
182+
<span class="d-inline-block" style="line-height: 120%;">
183+
<span style="color: #111;">
184+
<span class="placeholder" style="width: 85px;"></span><br>
185+
<small><span class="placeholder placeholder-sm" style="width: 55px;"></span></small>
186+
</span><br>
187+
<small class="puzzle-title mt-2"><span class="placeholder placeholder-sm" style="width: 110px;"></span></small>
188+
</span>
189+
</td>
190+
191+
<td class="player-name">
192+
<p class="mt-0 mb-1 d-sm-none">
193+
<small><span class="placeholder placeholder-sm" style="width: 65px;"></span></small><br>
194+
<small><span class="placeholder placeholder-sm" style="width: 45px;"></span></small>
195+
</p>
196+
<p class="mb-0 low-line-height">
197+
<small><span class="placeholder" style="width: 95px;"></span></small>
198+
</p>
199+
</td>
200+
201+
<td class="with-ppm text-end">
202+
<small style="line-height: 105%;"><span class="placeholder placeholder-sm" style="width: 55px;"></span></small><br>
203+
<span class="placeholder placeholder" style="width: 75px;">&nbsp;</span><br>
204+
<small class="text-nowrap"><span class="placeholder placeholder-sm" style="width: 50px;"></span></small>
205+
</td>
206+
</tr>
207+
{% endfor %}
208+
</tbody>
209+
</table>
210+
</div>
211+
{% endmacro %}

templates/hub.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<div class="tab-content">
3838
<div class="tab-pane fade show active" id="recent-activity" role="tabpanel">
39-
<twig:RecentActivity limit="20" :showLimit="4" />
39+
<twig:RecentActivity loading="lazy" limit="20" :showLimit="4" />
4040
</div>
4141

4242
<div class="tab-pane fade" id="recent-favorites-activity" role="tabpanel">
@@ -48,7 +48,7 @@
4848
<div>{{ 'hub.not_logged'|trans }}</div>
4949
</div>
5050
{% else %}
51-
<twig:RecentActivity limit="20" :showLimit="4" :favoritesOnly="true" />
51+
<twig:RecentActivity loading="lazy" limit="20" :showLimit="4" :favoritesOnly="true" />
5252
{% endif %}
5353
</div>
5454
</div>

0 commit comments

Comments
 (0)