Skip to content

Commit

Permalink
Merge pull request #145 from concord-consortium/187809702-fix-authore…
Browse files Browse the repository at this point in the history
…d-state-lookup

fix: Authored state lookup in authoring mode [PT-187809702]
  • Loading branch information
dougmartin authored Jun 20, 2024
2 parents cacc372 + 24602d1 commit 5440236
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/lara-app/components/authoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const AuthoringComponent = (props : IProps) => {
})}
</>
</select>
<div className={css.note}>Once you select an experiment please click the "Save authored state" button above to save your choice.</div>
</div>
);
};
16 changes: 13 additions & 3 deletions src/lara-app/hooks/interactive-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 5440236

Please sign in to comment.