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

Use Deep Links for Copying Multiplayer Join Code, Update Host Lobby Appearance #9153

Merged
merged 14 commits into from
Oct 27, 2022

Conversation

thsparks
Copy link
Contributor

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.

image

image

@eanders-ms
Copy link
Contributor

We should not show a space in the code:

image

Typing a space in the middle will be seen as an invalid join code.

@thsparks
Copy link
Contributor Author

We should not show a space in the code:

image

Typing a space in the middle will be seen as an invalid join code.

I updated the join code parsing to account for that. I think it's much easier to read with the space, personally...

{inviteString}
{inviteStringSegments[0]}
{
<a
Copy link
Contributor

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.

@@ -80,7 +80,7 @@ export function cleanupJoinCode(
joinCode: string | undefined
): string | undefined {
if (!joinCode) return undefined;
joinCode = joinCode.trim();
joinCode = joinCode.replaceAll(" ", "");
Copy link
Contributor

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.

Copy link
Member

@jwunderl jwunderl Oct 27, 2022

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 />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why show loading?

Copy link
Contributor Author

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.

Copy link
Contributor

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}");
Copy link
Contributor

Choose a reason for hiding this comment

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

nice :)

Copy link
Member

@jwunderl jwunderl left a 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]}
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

@jwunderl jwunderl Oct 27, 2022

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.
image
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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@eanders-ms eanders-ms left a 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.

@thsparks thsparks merged commit c1abcf5 into master Oct 27, 2022
@thsparks thsparks deleted the multiplayer/thsparks/rework_host_lobby branch October 27, 2022 23:53
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.

3 participants