perf: increase slots performance by 1500% !!!!
Some checks failed
CI / Get Changed Files (pull_request) Successful in 1m28s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker frontend validation (pull_request) Successful in 1m47s
CI / prettier (pull_request) Failing after 1m13s
CI / oxlint (pull_request) Successful in 1m28s
CI / eslint (pull_request) Successful in 1m32s
CI / Docker backend validation (pull_request) Successful in 3m1s
CI / test-build (pull_request) Successful in 29s

This commit is contained in:
Phan Huy Tran 2025-05-08 14:17:14 +02:00
commit e4f8127503
2 changed files with 19 additions and 12 deletions

View file

@ -9,15 +9,27 @@
<div class="card"> <div class="card">
<!-- Slot Machine Top --> <!-- Slot Machine Top -->
<div class="p-6"> <div class="p-6">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between gap-4">
<h2 class="text-xl font-bold text-white">Slot Machine</h2> <!-- Wrapper for title and win amount -->
<div class="flex items-baseline space-x-2">
<h2 class="text-xl font-bold text-white">Slot Machine</h2>
<span
*ngIf="slotResult().status === 'win' && slotResult().amount > 0"
class="text-emerald text-lg font-semibold"
aria-live="polite"
>
+{{ slotResult().amount | currency: 'EUR' }}
</span>
</div>
<!-- Status Badge -->
<div <div
[ngClass]="{ [ngClass]="{
'bg-emerald': slotResult().status === 'win', 'bg-emerald': slotResult().status === 'win',
'bg-accent-red': slotResult().status === 'lose', 'bg-accent-red': slotResult().status === 'lose',
'bg-deep-blue-light': slotResult().status === 'start', 'bg-deep-blue-light': slotResult().status === 'start',
}" }"
class="px-3 py-1 rounded-full text-sm font-semibold" class="px-3 py-1 rounded-full text-sm font-semibold whitespace-nowrap"
> >
<span class="text-white"> <span class="text-white">
{{ {{
@ -42,20 +54,15 @@
class="bg-deep-blue-contrast rounded-lg shadow-md p-2 flex items-center justify-center" class="bg-deep-blue-contrast rounded-lg shadow-md p-2 flex items-center justify-center"
> >
<span class="text-2xl font-bold" [ngClass]="getSymbolClass(cell)">{{ <span class="text-2xl font-bold" [ngClass]="getSymbolClass(cell)">{{
cell cell
}}</span> }}</span>
</div> </div>
} }
} }
</div> </div>
</div> </div>
<!-- Game Result --> <!-- Game Result (This section was removed as it's now at the top) -->
<div class="text-center mb-6" *ngIf="slotResult().status === 'win'">
<div class="text-emerald text-xl font-bold">
+{{ slotResult().amount | currency: 'EUR' }}
</div>
</div>
<!-- Controls --> <!-- Controls -->
<div class="flex flex-col sm:flex-row gap-4 items-center justify-center"> <div class="flex flex-col sm:flex-row gap-4 items-center justify-center">

View file

@ -119,7 +119,7 @@ export default class SlotsComponent implements OnInit, OnDestroy {
this.userService.refreshCurrentUser(); this.userService.refreshCurrentUser();
this.isSpinning = false; this.isSpinning = false;
}, 1500); }, 100);
}, },
error: (err) => { error: (err) => {
console.error('Error spinning slot machine:', err); console.error('Error spinning slot machine:', err);