A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: do not discard hash route on navigation
thecodrr0b390c966868
diff --git a/apps/web/src/components/dialogs/buydialog.js b/apps/web/src/components/dialogs/buydialog.jsindex b6578a588..5067f2d27 100644--- a/apps/web/src/components/dialogs/buydialog.js+++ b/apps/web/src/components/dialogs/buydialog.js@@ -14,6 +14,7 @@ import { ReactComponent as WorkLate } from "../../assets/worklate.svg";import Loader from "../loader";import Field from "../field";import { useSessionState } from "../../utils/hooks";+import { hardNavigate } from "../../navigation";const sections = [{@@ -362,6 +363,7 @@ function BuyDialog(props) {<SelectedPlanplan={{ ...selectedPlan, ...discount }}onPlanChangeRequest={() => setSelectedPlan()}+ isPlanChangeable={!plan}onCouponApplied={(coupon) => {setDiscount({ isApplyingCoupon: true });setSelectedPlan((plan) => ({ ...plan, coupon }));@@ -376,7 +378,7 @@ function BuyDialog(props) {/>)) : (- <TryForFree />+ <TryForFree couponCode={couponCode} />)}</Flex>{isLoggedIn ? (@@ -626,7 +628,7 @@ function ChooseAPlan({ selectedPlan, onPlanChanged }) {);}-function TryForFree() {+function TryForFree({ couponCode }) {return (<><Rocket width={200} />@@ -636,14 +638,31 @@ function TryForFree() {<Text variant="body" textAlign="center" mt={1}>Ready to take the next step in your private note taking journey?</Text>- <Button variant="primary" mt={4}>- Try free for 14 days+ <Button variant="primary" mt={4} onClick={() => hardNavigate("/signup")}>+ {couponCode ? "Claim my discount" : "Try free for 14 days"}</Button>+ {couponCode && (+ <Text+ variant="subBody"+ bg="shade"+ color="primary"+ mt={4}+ p={1}+ sx={{ borderRadius: "default" }}+ >+ Please sign up or login to use your coupon: <b>{couponCode}</b>+ </Text>+ )}</>);}-function SelectedPlan({ plan, onPlanChangeRequest, onCouponApplied }) {+function SelectedPlan({+ plan,+ isPlanChangeable,+ onPlanChangeRequest,+ onCouponApplied,+}) {useEffect(() => {const couponInput = document.getElementById("coupon");couponInput.value = plan.coupon ? plan.coupon : couponInput.value;@@ -698,9 +717,11 @@ function SelectedPlan({ plan, onPlanChangeRequest, onCouponApplied }) {discountedPrice={plan.discount || 0.0}isRecurringDiscount={plan.isRecurringDiscount}/>- <Button variant="secondary" mt={4} px={4} onClick={onPlanChangeRequest}>- Change plan- </Button>+ {isPlanChangeable && (+ <Button variant="secondary" mt={4} px={4} onClick={onPlanChangeRequest}>+ Change plan+ </Button>+ )}</>);}diff --git a/apps/web/src/index.js b/apps/web/src/index.jsindex 3598f3438..335f00e1f 100644--- a/apps/web/src/index.js+++ b/apps/web/src/index.js@@ -1,5 +1,5 @@import { render } from "react-dom";-import { getCurrentPath } from "./navigation";+import { getCurrentHash, getCurrentPath, makeURL } from "./navigation";import * as serviceWorker from "./serviceWorkerRegistration";import { isTesting } from "./utils/platform";if (process.env.REACT_APP_PLATFORM === "desktop") require("./commands");@@ -31,7 +31,7 @@ const ROUTES = {function getRoute() {const path = getCurrentPath();if (!isTesting() && !shouldSkipInitiation() && !ROUTES[path]) {- window.history.replaceState({}, null, "/signup");+ window.history.replaceState({}, null, makeURL("/signup", getCurrentHash()));return ROUTES["/signup"];}return ROUTES[path] || ROUTES.default;diff --git a/apps/web/src/navigation/index.js b/apps/web/src/navigation/index.jsindex 2e0811141..6c0bc9f26 100644--- a/apps/web/src/navigation/index.js+++ b/apps/web/src/navigation/index.js@@ -20,7 +20,11 @@ export function navigate(url, replaceOrQuery, replace) {replace = false;}- window.history[`${replace ? "replace" : "push"}State`](null, null, url);+ window.history[`${replace ? "replace" : "push"}State`](+ null,+ null,+ makeURL(url, getCurrentHash())+ );dispatchEvent(new PopStateEvent("popstate", null));}let last = 0;@@ -97,5 +101,11 @@ export function extendHomeRoute(route) {}export function hardNavigate(route) {- window.open(route, "_self");+ window.open(makeURL(route, getCurrentHash()), "_self");+}++export function makeURL(route, hash) {+ const url = new URL(route, window.location.origin);+ url.hash = hash || getCurrentHash();+ return url;}