Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor UI and State Management for Checkbox and Button Handling #130

Merged
merged 8 commits into from
Aug 28, 2024

Conversation

itailiors
Copy link
Collaborator

No description provided.

@itailiors
Copy link
Collaborator Author

itailiors commented Jul 23, 2024

Updated the Claim Coins button to be enabled only if at least one checkbox for the specified stage is selected.
In general, fixed these issues:

  1. The claim coins button was activated even when you didn't choose any checkbox, so you would press claimCoins and just get an error.
  2. You could claim coins (trxId) for a different stage (steps to reproduce are to check a checkBox from stage 2 and claim coins for 3, there was a bug there, but handling it like this solves it without the headache).
  3. IMO looks cool

@itailiors itailiors marked this pull request as ready for review August 7, 2024 09:48
}
@foreach (var project in projects)
{
Stats.TryGetValue(project.ProjectInfo.ProjectIdentifier, out var stats);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice your IDE will align lines incorrectly, this line of code should be pushed one tab to the right, I think its an IDE issue

@@ -653,4 +688,31 @@
await _clipboardService.WriteTextAsync(trxData);
StateHasChanged();
}

public struct UtxoKey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already such a type its called Outpoint use that instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check it out 👍

@@ -85,7 +85,7 @@
@if (stageisActive)
{

<button class="btn @((noCoinsToClaim) ? "btn-light" : "btn-success")" disabled="@noCoinsToClaim" @onclick="() => ClaimCoinsCheckPassword(stage.StageIndex)">
<button class="btn @((noCoinsToClaim) ? "btn-light" : "btn-success")" disabled="@((noCoinsToClaim || !IsCheckboxSelectedForStage(stage.StageIndex)))" @onclick="() => ClaimCoinsCheckPassword(stage.StageIndex)">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be much simplified, when we expand another stage we clear the dictionary so there will only be items for a particular stage right? so you just need to check if the dictionary selectedUtxos has items in it, correct me if I am wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noCoinsToClaim is determined by investedCount == 0 or stage.StagePinner == true.
there might be a scenario where selectedUtxos has values for stage 2. In this case, the claimCoins option for stage 1 won't be disabled.
providing the stageIndex and the relevant method, we can handle the logic for each stage appropriately.

}
else
{
selected.Add(trxId, null);
selectedUtxos[key] = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be true, we wont have a case that the value is false right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the key means it no longer exists in the dictionary, so there isn't a false value associated with it?
if so then i think you're right

return Trxid == key.Trxid && Outputindex == key.Outputindex;
}

public override int GetHashCode()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see you need to compile a hashcode for the dictionary unique key.
instead of using a new type it would be simpler to use a string of "trxid-index", but keep this as it is.

@dangershony dangershony merged commit 21f0296 into main Aug 28, 2024
2 of 3 checks passed
@dangershony dangershony deleted the claim-coins-fix branch August 28, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants