Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ui/lobby/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export default class LobbyController {

const locationHash = location.hash.replace('#', '');
if (['ai', 'friend', 'hook'].includes(locationHash)) {
let friendUser: string;
const forceOptions: ForceSetupOptions = {};
const urlParams = new URLSearchParams(location.search);
const friendUser = urlParams.get('user') ?? undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is adding ?? undefined necessary here?

Copy link
Author

Choose a reason for hiding this comment

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

params.get(...) returns null when the parameter is not found (i.e. string | null), but the friendUser argument of openModal a few lines below accepts string | undefined, so the null value has to be converted to undefined.

if (locationHash === 'hook') {
if (urlParams.get('time') === 'realTime') {
this.tab = 'real_time';
Expand All @@ -88,8 +88,6 @@ export default class LobbyController {
} else if (urlParams.get('fen')) {
forceOptions.fen = urlParams.get('fen')!;
forceOptions.variant = 'fromPosition';
} else {
friendUser = urlParams.get('user')!;
}

loadDialogPolyfill.then(() => {
Expand Down