diff --git a/src/lara-app/components/authoring.tsx b/src/lara-app/components/authoring.tsx index ff9805f..ff27f7a 100644 --- a/src/lara-app/components/authoring.tsx +++ b/src/lara-app/components/authoring.tsx @@ -38,7 +38,6 @@ export const AuthoringComponent = (props : IProps) => { })} -
Once you select an experiment please click the "Save authored state" button above to save your choice.
); }; diff --git a/src/lara-app/hooks/interactive-api.ts b/src/lara-app/hooks/interactive-api.ts index 857448b..48d7a8e 100644 --- a/src/lara-app/hooks/interactive-api.ts +++ b/src/lara-app/hooks/interactive-api.ts @@ -70,9 +70,19 @@ export const useInteractiveApi = (options: {setError: (error: any) => void}) => setConnectedToLara(true); let _experiment; - if (data.authoredState && (data.authoredState.version === "1.0")) { - experimentId.current = data.authoredState.experimentId; - _experiment = findExperiment(data.authoredState.experimentId); + let authoredState = data.authoredState; + // In authoring mode the authored state comes in as a string + // which causes the authoring preview to show an error + if (typeof authoredState === "string") { + try { + authoredState = JSON.parse(authoredState); + } catch (e) { + // noop + } + } + if (authoredState?.version === "1.0") { + experimentId.current = authoredState.experimentId; + _experiment = findExperiment(authoredState.experimentId); setExperiment(_experiment); } @@ -119,6 +129,7 @@ export const useInteractiveApi = (options: {setError: (error: any) => void}) => if (data.mode === "runtime" && isGetFirebaseJwtSupported(data)) { _phone.addListener("firebaseJWT", (result: any) => { + debugger; if (result.response_type === "ERROR") { // Switch to preview mode. Most likely it means that user is not logged in (anonymous), a teacher, // or a student running the activity not from the Portal. In all that cases API will return