From 438b54d1d0604109aa4b6bacdf11cf716b5638aa Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Thu, 5 May 2022 14:36:28 -0500 Subject: [PATCH] oops phrase URL sharing bug fixed hopefull --- package.json | 2 +- src/components/vp-explorer/VPExplorer.tsx | 19 +++++++++++-------- src/components/vp-explorer/vps-reducer.ts | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 1f227aa..15a7edc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.4.1", + "version": "2.4.2", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/components/vp-explorer/VPExplorer.tsx b/src/components/vp-explorer/VPExplorer.tsx index 06099ac..0992aff 100644 --- a/src/components/vp-explorer/VPExplorer.tsx +++ b/src/components/vp-explorer/VPExplorer.tsx @@ -66,9 +66,19 @@ function VPExplorer(props: { setAlert(undefined); }, 1500); } + // useEffect(() => { + // const newVps = makeVPSelectionState(props.verb, vps); + // adjustVps({ + // type: "load vps", + // payload: newVps, + // }); + // // eslint-disable-next-line + // }, [props.verb]); useEffect(() => { const VPSFromUrl = getVPSFromUrl(); + console.log({ VPSFromUrl }); if (VPSFromUrl) { + setMode("phrases"); adjustVps({ type: "load vps", payload: VPSFromUrl @@ -76,14 +86,6 @@ function VPExplorer(props: { } // eslint-disable-next-line }, []); - useEffect(() => { - const newVps = makeVPSelectionState(props.verb, vps); - adjustVps({ - type: "load vps", - payload: newVps, - }); - // eslint-disable-next-line - }, [props.verb]); function handleSubjectChange(subject: T.NPSelection | undefined, skipPronounConflictCheck?: boolean) { adjustVps({ type: "set subject", @@ -270,6 +272,7 @@ function getShareUrl(vps: T.VPSelectionState): string { const stringJSON = JSON.stringify(vps); const encoded = LZString.compressToEncodedURIComponent(stringJSON); const url = new URL(window.location.href); + url.searchParams.delete(phraseURLParam); url.searchParams.append(phraseURLParam, encoded); return url.toString(); } diff --git a/src/components/vp-explorer/vps-reducer.ts b/src/components/vp-explorer/vps-reducer.ts index e2a4892..14f3c07 100644 --- a/src/components/vp-explorer/vps-reducer.ts +++ b/src/components/vp-explorer/vps-reducer.ts @@ -62,6 +62,7 @@ export function vpsReducer(vps: T.VPSelectionState, action: VpsReducerAction, se } function doReduce(): T.VPSelectionState { if (action.type === "load vps") { + console.log("doing loading", action.payload); return action.payload; } if (action.type === "set subject") {