oops phrase URL sharing bug fixed hopefull

This commit is contained in:
lingdocs 2022-05-05 14:36:28 -05:00
parent 002cfbadda
commit 438b54d1d0
3 changed files with 13 additions and 9 deletions

View File

@ -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",

View File

@ -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();
}

View File

@ -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") {