Skip to content

Commit

Permalink
Tweak ChallengeModal for optional close button and Create Game text
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Oct 16, 2024
1 parent 0fd5c83 commit 97d00e9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/components/ChallengeModal/ChallengeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class ChallengeModal extends Modal<Events, ChallengeModalProperties, any>
export class ChallengeModalBody extends React.Component<
ChallengeModalProperties & {
modal: {
close: () => void;
close?: () => void;
on: (event: "open" | "close", callback: () => void) => void;
off: (event: "open" | "close", callback: () => void) => void;
};
Expand All @@ -170,7 +170,7 @@ export class ChallengeModalBody extends React.Component<
constructor(
props: ChallengeModalProperties & {
modal: {
close: () => void;
close?: () => void;
on: (event: "open" | "close", callback: () => void) => void;
off: (event: "open" | "close", callback: () => void) => void;
};
Expand Down Expand Up @@ -320,7 +320,7 @@ export class ChallengeModalBody extends React.Component<
if (this.props.autoCreate) {
setTimeout(() => {
this.createChallenge();
this.props.modal.close();
this.props.modal.close?.();
}, 1);
}

Expand Down Expand Up @@ -519,7 +519,7 @@ export class ChallengeModalBody extends React.Component<

console.log("Sending", settings);
this.saveSettings();
this.props.modal.close();
this.props.modal.close?.();

if (this.props.game_record_mode) {
settings.library_collection_id = this.props.libraryCollectionId;
Expand Down Expand Up @@ -678,7 +678,7 @@ export class ChallengeModalBody extends React.Component<
*/

this.saveSettings();
this.props.modal.close();
this.props.modal.close?.();

post(player_id ? `players/${player_id}/challenge` : "challenges", challenge)
.then((res) => {
Expand Down Expand Up @@ -1802,7 +1802,11 @@ export class ChallengeModalBody extends React.Component<
</div>
)} */}
<div className="buttons">
<button onClick={this.props.modal.close}>{_("Close")}</button>
{this.props.modal.close ? (
<button onClick={this.props.modal.close}>{_("Close")}</button>
) : (
<span />
)}
{mode === "demo" && (
<button onClick={this.createDemo} className="primary">
{this.props.game_record_mode
Expand All @@ -1826,7 +1830,7 @@ export class ChallengeModalBody extends React.Component<
className="primary"
disabled={this.state.input_value_warning}
>
{_("Create Challenge")}
{pgettext("Create a game anyone can join", "Create Game")}
</button>
)}
</div>
Expand Down

0 comments on commit 97d00e9

Please sign in to comment.