Skip to content

Commit d6c3bfe

Browse files
SimYunSupclaude
andcommitted
fix: Keep draw button disabled until all draws complete
Resolve issue where the draw button becomes enabled after the first person is drawn when drawing multiple people. Track the number of pending draws (PendingDrawCount) and only set status to Done after all draws have completed. Add Disabled attribute to the button to prevent users from clicking the draw button again while the animation is still in progress for multiple draws. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e6d9707 commit d6c3bfe

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/DotNetDevLottery/Components/Random/MachineAnimation.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<FluentButton
1818
OnClick="OnClickButton"
1919
Appearance="@(Status == DrawMachineStatus.Pending ? Appearance.Neutral : Appearance.Accent)"
20+
Disabled="@(Status == DrawMachineStatus.Pending)"
2021
class="@TriggerButtonClass(Status == DrawMachineStatus.Pending)">
2122
추첨 진행
2223
</FluentButton>

src/DotNetDevLottery/Components/Random/MachineAnimation.razor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public partial class MachineAnimation : ComponentBase, IAsyncDisposable
3737
int PersonCount = 0;
3838
int TargetPersonCount = 1;
3939
int RemainedPersonCount = 0;
40+
int PendingDrawCount = 0;
4041
List<int> WinnedUserList = new List<int>();
4142
BallDesignSettings ballSettings = new();
4243
string BallStyleVariables => GenerateBallStyleVariables();
@@ -117,6 +118,7 @@ public async Task OnClickButton()
117118
}
118119
SelectedUserInfo = null;
119120
Status = DrawMachineStatus.Pending;
121+
PendingDrawCount = TargetPersonCount;
120122
Console.WriteLine($"TargetPersonCount: {TargetPersonCount}");
121123
await machineUtils.InvokeVoidAsync("executeDrawBall", TargetPersonCount);
122124
await OnBeforeDrawMachine.InvokeAsync();
@@ -158,7 +160,12 @@ public async Task OnDrawMachineAnimationEnd()
158160
{
159161
return;
160162
}
161-
Status = DrawMachineStatus.Done;
163+
PendingDrawCount--;
164+
165+
if (PendingDrawCount <= 0)
166+
{
167+
Status = DrawMachineStatus.Done;
168+
}
162169

163170
await OnDrawAnimationEnd.InvokeAsync(new DrawAnimationEndEventArgs
164171
{

0 commit comments

Comments
 (0)