Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
update: popup the dialog warning at a later stage of registration
Browse files Browse the repository at this point in the history
  • Loading branch information
yaya-usman committed Apr 21, 2022
1 parent 872d0e0 commit 9fe77a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/components/structures/auth/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,8 @@ export default class Registration extends React.Component<IProps, IState> {

componentDidMount() {
this.replaceClient(this.props.serverConfig);
//triggers a confirmation dialog for data loss before page unloads/refreshes
window.addEventListener("beforeunload", this.unloadCallback);
}

componentWillUnmount() {
window.removeEventListener("beforeunload", this.unloadCallback);
}

private unloadCallback = (event: BeforeUnloadEvent) => {
event.preventDefault();
event.returnValue = "";
return "";
};

// TODO: [REACT-WARNING] Replace with appropriate lifecycle event
// eslint-disable-next-line
UNSAFE_componentWillReceiveProps(newProps) {
Expand Down
9 changes: 9 additions & 0 deletions src/components/views/auth/CaptchaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ export default class CaptchaForm extends React.Component<ICaptchaFormProps, ICap
);
this.recaptchaContainer.current.appendChild(scriptTag);
}
//triggers a confirmation dialog for data loss before page unloads/refreshes
window.addEventListener("beforeunload", this.unloadCallback);
}

componentWillUnmount() {
this.resetRecaptcha();
window.removeEventListener("beforeunload", this.unloadCallback);
}

private unloadCallback = (event: BeforeUnloadEvent) => {
event.preventDefault();
event.returnValue = "";
return "";
};

// Borrowed directly from: https://github.com/codeep/react-recaptcha-google/commit/e118fa5670fa268426969323b2e7fe77698376ba
private isRecaptchaReady(): boolean {
return typeof window !== "undefined" &&
Expand Down
12 changes: 12 additions & 0 deletions src/components/views/auth/InteractiveAuthEntryComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,20 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms

componentDidMount() {
this.props.onPhaseChange(DEFAULT_PHASE);
//triggers a confirmation dialog for data loss before page unloads/refreshes
window.addEventListener("beforeunload", this.unloadCallback);
}

componentWillUnmount() {
window.removeEventListener("beforeunload", this.unloadCallback);
}

private unloadCallback = (event: BeforeUnloadEvent) => {
event.preventDefault();
event.returnValue = "";
return "";
};

private togglePolicy(policyId: string) {
const newToggles = {};
for (const policy of this.state.policies) {
Expand Down

0 comments on commit 9fe77a8

Please sign in to comment.