perf: increase slots performance by 1500% !!!! #174

Merged
ptran merged 2 commits from perf-slots into main 2025-05-08 12:23:32 +00:00
2 changed files with 17 additions and 10 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">
{{ {{
@ -50,12 +62,7 @@
</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);