Skip to content

Commit

Permalink
Merge pull request #40 from equinor/fix/tutorial-bug
Browse files Browse the repository at this point in the history
🐛 Make tutorials from params have precedence over tutorials that should popup
  • Loading branch information
aslakihle authored Oct 23, 2024
2 parents 1eb95bb + 96d345e commit d53af25
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/subsurface-app-management",
"version": "1.1.16",
"version": "1.1.17",
"description": "React Typescript components/hooks to communicate with equinor/sam",
"types": "dist/index.d.ts",
"type": "module",
Expand Down
21 changes: 12 additions & 9 deletions src/providers/TutorialProvider/TutorialProviderInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,19 @@ const TutorialProviderInner: FC = () => {

useEffect(() => {
if (tutorialsForPath.length < 1) return;
const tutorialToRun = tutorialsForPath.find(
(item) =>
!window.localStorage.getItem(item.shortName) ||
(shortNameFromParams &&
tutorialsForPath.some(
(item) => item.shortName === shortNameFromParams
))

const tutorialToRunFromParams = tutorialsForPath.find(
(item) => item.shortName === shortNameFromParams
);

const tutorialThatShouldPopUp = tutorialsForPath.find(
(item) => !window.localStorage.getItem(item.shortName) && item.willPopUp
);
if (tutorialToRun) {
runTutorial(tutorialToRun);

if (tutorialToRunFromParams) {
runTutorial(tutorialToRunFromParams);
} else if (tutorialThatShouldPopUp) {
runTutorial(tutorialThatShouldPopUp);
}
}, [runTutorial, shortNameFromParams, tutorialsForPath]);

Expand Down

0 comments on commit d53af25

Please sign in to comment.