From 43d579744fe74db0c56465aa5c75f888c0692ff4 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 29 Apr 2022 19:25:00 +0100 Subject: [PATCH 1/4] Put PTT behind 'feature flag' AKA does the URL hash start with '#ptt' This will let us merge PTT back to the main branch --- .vscode/settings.json | 4 ++-- src/home/RegisteredView.jsx | 5 +++-- src/home/UnauthenticatedView.jsx | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a681c9e..ade5051 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "editor.formatOnSave": true, + "editor.formatOnSave": false, "editor.insertSpaces": true, "editor.tabSize": 2 -} \ No newline at end of file +} diff --git a/src/home/RegisteredView.jsx b/src/home/RegisteredView.jsx index 6849d9f..9ef5b2a 100644 --- a/src/home/RegisteredView.jsx +++ b/src/home/RegisteredView.jsx @@ -13,6 +13,7 @@ import { JoinExistingCallModal } from "./JoinExistingCallModal"; import { useHistory } from "react-router-dom"; import { Headline, Title } from "../typography/Typography"; import { Form } from "../form/Form"; +import { shouldShowPtt } from "../shouldShowPtt"; export function RegisteredView({ client }) { const [loading, setLoading] = useState(false); @@ -98,14 +99,14 @@ export function RegisteredView({ client }) { {loading ? "Loading..." : "Go"} - + {shouldShowPtt() && - + } {error && ( {error.message} diff --git a/src/home/UnauthenticatedView.jsx b/src/home/UnauthenticatedView.jsx index b39bfc7..005dc73 100644 --- a/src/home/UnauthenticatedView.jsx +++ b/src/home/UnauthenticatedView.jsx @@ -15,6 +15,7 @@ import { Form } from "../form/Form"; import styles from "./UnauthenticatedView.module.css"; import commonStyles from "./common.module.css"; import { generateRandomName } from "../auth/generateRandomName"; +import { shouldShowPtt } from "../shouldShowPtt"; export function UnauthenticatedView() { const [loading, setLoading] = useState(false); @@ -112,14 +113,14 @@ export function UnauthenticatedView() { autoComplete="off" /> - + {shouldShowPtt() && - + } By clicking "Go", you agree to our{" "} Terms and conditions From 0814e3c905b3b72142f7c48147974dafd6238a4d Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 3 May 2022 12:05:22 +0100 Subject: [PATCH 2/4] Revert unintentional commit --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ade5051..6889f44 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "editor.formatOnSave": false, + "editor.formatOnSave": true, "editor.insertSpaces": true, "editor.tabSize": 2 } From be01a4bd818ef3cefba3da471dccbf19ad8c75d1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 3 May 2022 12:05:40 +0100 Subject: [PATCH 3/4] Commit missed file --- src/shouldShowPtt.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/shouldShowPtt.js diff --git a/src/shouldShowPtt.js b/src/shouldShowPtt.js new file mode 100644 index 0000000..a1b68e5 --- /dev/null +++ b/src/shouldShowPtt.js @@ -0,0 +1,3 @@ +export function shouldShowPtt() { + return window.location.hash.startsWith('#ptt'); +} \ No newline at end of file From dbdb82bd749afa182210393e2fd1f57085cda480 Mon Sep 17 00:00:00 2001 From: Robert Long Date: Tue, 3 May 2022 10:32:06 -0700 Subject: [PATCH 4/4] Switch to useShouldShowPtt hook --- src/home/RegisteredView.jsx | 21 ++++++++++++--------- src/home/UnauthenticatedView.jsx | 21 ++++++++++++--------- src/shouldShowPtt.js | 3 --- src/useShouldShowPtt.js | 6 ++++++ 4 files changed, 30 insertions(+), 21 deletions(-) delete mode 100644 src/shouldShowPtt.js create mode 100644 src/useShouldShowPtt.js diff --git a/src/home/RegisteredView.jsx b/src/home/RegisteredView.jsx index 9ef5b2a..0480050 100644 --- a/src/home/RegisteredView.jsx +++ b/src/home/RegisteredView.jsx @@ -13,12 +13,13 @@ import { JoinExistingCallModal } from "./JoinExistingCallModal"; import { useHistory } from "react-router-dom"; import { Headline, Title } from "../typography/Typography"; import { Form } from "../form/Form"; -import { shouldShowPtt } from "../shouldShowPtt"; +import { useShouldShowPtt } from "../useShouldShowPtt"; export function RegisteredView({ client }) { const [loading, setLoading] = useState(false); const [error, setError] = useState(); const history = useHistory(); + const shouldShowPtt = useShouldShowPtt(); const onSubmit = useCallback( (e) => { e.preventDefault(); @@ -99,14 +100,16 @@ export function RegisteredView({ client }) { {loading ? "Loading..." : "Go"} - {shouldShowPtt() && - - } + {shouldShowPtt && ( + + + + )} {error && ( {error.message} diff --git a/src/home/UnauthenticatedView.jsx b/src/home/UnauthenticatedView.jsx index 005dc73..8243510 100644 --- a/src/home/UnauthenticatedView.jsx +++ b/src/home/UnauthenticatedView.jsx @@ -15,9 +15,10 @@ import { Form } from "../form/Form"; import styles from "./UnauthenticatedView.module.css"; import commonStyles from "./common.module.css"; import { generateRandomName } from "../auth/generateRandomName"; -import { shouldShowPtt } from "../shouldShowPtt"; +import { useShouldShowPtt } from "../useShouldShowPtt"; export function UnauthenticatedView() { + const shouldShowPtt = useShouldShowPtt(); const [loading, setLoading] = useState(false); const [error, setError] = useState(); const [{ privacyPolicyUrl, recaptchaKey }, register] = @@ -113,14 +114,16 @@ export function UnauthenticatedView() { autoComplete="off" /> - {shouldShowPtt() && - - } + {shouldShowPtt && ( + + + + )} By clicking "Go", you agree to our{" "} Terms and conditions diff --git a/src/shouldShowPtt.js b/src/shouldShowPtt.js deleted file mode 100644 index a1b68e5..0000000 --- a/src/shouldShowPtt.js +++ /dev/null @@ -1,3 +0,0 @@ -export function shouldShowPtt() { - return window.location.hash.startsWith('#ptt'); -} \ No newline at end of file diff --git a/src/useShouldShowPtt.js b/src/useShouldShowPtt.js new file mode 100644 index 0000000..606a689 --- /dev/null +++ b/src/useShouldShowPtt.js @@ -0,0 +1,6 @@ +import { useLocation } from "react-router-dom"; + +export function useShouldShowPtt() { + const { hash } = useLocation(); + return hash.startsWith("#ptt"); +}