-
Notifications
You must be signed in to change notification settings - Fork 587
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
Use Deep Links for Copying Multiplayer Join Code, Update Host Lobby Appearance #9153
Conversation
…m the join code's appearance.
…layer/thsparks/rework_host_lobby
{inviteString} | ||
{inviteStringSegments[0]} | ||
{ | ||
<a |
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.
Use Link
component from react-common, rather than a
.
multiplayer/src/util/index.ts
Outdated
@@ -80,7 +80,7 @@ export function cleanupJoinCode( | |||
joinCode: string | undefined | |||
): string | undefined { | |||
if (!joinCode) return undefined; | |||
joinCode = joinCode.trim(); | |||
joinCode = joinCode.replaceAll(" ", ""); |
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.
Oh I see, this will remove the space. Maybe it's fine.
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.
Should we maybe just move line 85 up and delete this / line 84? That should handle this just fine as it's already clearing out all non alphanumeric already (which would fix if there's a weird nbsp or something)
}; | ||
const joinCode = state.gameState?.joinCode; | ||
if (!joinCode) { | ||
return <Loading />; |
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.
Why show loading?
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.
It was just something so it wasn't empty, but this case shouldn't ever really happen. It can be null instead if you think that's better.
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.
null is better, but not worth holding this PR
}; | ||
// To get a link in the middle of the invite string, we actually preserve the {0} and insert the link manually as an html element later. | ||
const inviteString = lf("Go to {0} and enter code", "{0}"); | ||
const inviteStringSegments = inviteString.split("{0}"); |
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.
nice :)
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.
LGTM besides using link component instead of anchor directly as eric mentioned~
return ( | ||
<div className="tw-flex tw-flex-col tw-gap-1 tw-items-center tw-justify-between tw-bg-white tw-py-[3rem] tw-px-[7rem] tw-shadow-lg tw-rounded-lg"> | ||
<div className="tw-mt-3 tw-text-lg tw-text-center tw-text-neutral-700"> | ||
{inviteString} | ||
{inviteStringSegments[0]} |
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.
Assuming the number of elements in inviteStringSegments feels brittle to me. And assuming the link is in the middle segment isn't a safe assumption. I think you will need to iterate over the segments, and replace the one matching "{0}" with the link.
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.
Hmm, currently we split on {0} so there's no actual segment containing it. The only scenario where there wouldn't be 2 segments is if it was at the beginning or the end, so would it be better if we simply checked startsWith and endsWith {0} and reacted accordingly?
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 guess if {0} ended up in multiple places that'd also mess things up but I don't expect that would happen as a result of localization.
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.
split will leave an empty string at beginning / end if the the string starts with / ends with it so that would still be fine, e.g.
I guess if the translation doubled up the link it would be an issue, but that would be pretty weird / we do this in a few other locations already and haven't seen that before?
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 I would split on whitespace and find the {0}. You could optimize by rejoining the contiguous word sequences before and after it. Do this in a useMemo.
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.
But there a ways of solving 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.
What's the benefit? Feels like unnecessary complexity to me.
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.
Leaving this as-is for now b/c time crunch, but we can follow up later to understand concerns and address as needed.
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.
After approving, I noticed the issue with inviteStringSegments.
This updates the host lobby appearance to match the latest designs more closely, and it will copy a deep link rather than the code itself when the copy button is pressed (on both the host lobby and the game page).
Also sneaking in a fix to make the sim use the full screen width when on a smaller screen.