-
Notifications
You must be signed in to change notification settings - Fork 41
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
Automate turn based card draw. #116
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
20da612
feat: automate card draw tx submission on turn change
ultraviolet10 4dc64c0
fix: check if null
ultraviolet10 0f9480a
fix: remove unused import
ultraviolet10 8d4b4dd
fix: comment formatting for accurate linking
ultraviolet10 b40347d
fix: update `privateInfo` atom dependencies
ultraviolet10 2d8e364
fix: typo
ultraviolet10 26a223e
fix: update `getPrivateInfo`
ultraviolet10 2c8fdef
feat: scrolling effect in `Hand` upon drawing new card, toast notific…
ultraviolet10 58690e3
fix: minor
ultraviolet10 e13fba6
fix: `useScrollbox` hook
ultraviolet10 7868671
fix: use accurate type for `ref` param
ultraviolet10 3a4501b
chore: show `draw` button if useEffect call fails
ultraviolet10 83e9d00
chore: use placeholder `setLoading` function
ultraviolet10 467a7df
update deps
ultraviolet10 41c691a
fix: trigger error modal
ultraviolet10 b63a0ec
update `pnpm-lock`
ultraviolet10 2e4d0fe
feat: kill toast upon draw + pop up card drawer
ultraviolet10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,10 @@ export async function drawCard(args: DrawCardArgs): Promise<boolean> { | |
} | ||
} | ||
|
||
/** Intentionally left blank to ignore any loading message. | ||
* This function accepts a message parameter but does nothing with it. */ | ||
function setLoading(_message: string|null|undefined) {} | ||
|
||
async function drawCardImpl(args: DrawCardArgs): Promise<boolean> { | ||
|
||
const gameID = getGameID() | ||
|
@@ -92,7 +96,7 @@ async function drawCardImpl(args: DrawCardArgs): Promise<boolean> { | |
const cards = getCards()! | ||
console.log(`drew card ${cards[selectedCard]}`) | ||
|
||
args.setLoading("Generating draw proof ...") | ||
setLoading("Generating draw proof ...") | ||
|
||
const tmpHandSize = privateInfo.handIndexes.indexOf(255) | ||
const initialHandSize = tmpHandSize < 0 | ||
|
@@ -138,7 +142,7 @@ async function drawCardImpl(args: DrawCardArgs): Promise<boolean> { | |
proof.proof_b, | ||
proof.proof_c | ||
], | ||
setLoading: args.setLoading | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cf. above comment |
||
setLoading: setLoading | ||
}))) | ||
|
||
// TODO: this should be put in an optimistic store, before proof generation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useTheme } from "next-themes" | ||
import { Toaster as Sonner } from "sonner" | ||
|
||
type ToasterProps = React.ComponentProps<typeof Sonner> | ||
|
||
// ref: https://ui.shadcn.com/docs/components/sonner | ||
// docs: https://sonner.emilkowal.ski/ | ||
const Toaster = ({ ...props }: ToasterProps) => { | ||
const { theme = "system" } = useTheme() | ||
|
||
return ( | ||
<Sonner | ||
theme={theme as ToasterProps["theme"]} | ||
className="toaster group" | ||
toastOptions={{ | ||
classNames: { | ||
toast: | ||
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg", | ||
description: "group-[.toast]:text-muted-foreground", | ||
actionButton: | ||
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground", | ||
cancelButton: | ||
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground", | ||
}, | ||
}} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
export { Toaster } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we kept this logic (which is useful for debugging), but simply ignored it by supplying a custom
setLoading
function that ignores it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something as simple as:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should handle the case where it is set to null to make the toast go away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toast disappears in a couple of seconds as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to make the call we need to dismiss it — as if it overlaps with the card being highlighted, which is really "eh".
Also, we should "pop up" the hand (as if it was hovered by the cursor, even if it isn't) at least for the time of the card highlight. I would make the card highlight time a tad longer as well (maybe 3s instead of 2.5?)