Skip to content

Commit

Permalink
Merge pull request #215 from Sunbird-ALL/all-1.3-tn-dev-hotfix
Browse files Browse the repository at this point in the history
All 1.3 tn dev hotfix
  • Loading branch information
gouravmore authored Nov 15, 2024
2 parents 921d1c9 + ad4c5f3 commit f77e5b4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
35 changes: 20 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import theme from "./assets/styles/theme";
import { initialize } from "./services/telementryService";
import { startEvent } from "./services/callTelemetryIntract";
import "@project-sunbird/telemetry-sdk/index.js";
import { getParameter } from "./utils/constants";

const App = () => {
const ranonce = useRef(false);
Expand Down Expand Up @@ -72,22 +73,26 @@ const App = () => {
}, []);

useEffect(() => {
const handleMessage = (event) => {
// Destructure the message data
const { messageType, localStorageKeyValue } = event.data;
if (messageType === "customData") {
for (const item of localStorageKeyValue) {
const key = item.key;
const value = item.value;
let virtualId;

localStorage.setItem(key, value);
}
}
};
window.addEventListener("message", handleMessage);
return () => {
window.removeEventListener("message", handleMessage);
};
if (getParameter("virtualId", window.location.search)) {
virtualId = getParameter("virtualId", window.location.search);
} else {
virtualId = localStorage.getItem("virtualId");
}
localStorage.setItem("virtualId", virtualId);

const contentSessionId = getParameter(
"contentSessionId",
window.location.search
);
if (contentSessionId) {
localStorage.setItem("contentSessionId", contentSessionId);
}
const token = getParameter("token", window.location.search);
if (token) {
localStorage.setItem("token", token);
}
}, []);

return (
Expand Down
10 changes: 9 additions & 1 deletion src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SelectLanguageButton,
StartAssessmentButton,
getLocalData,
getParameter,
languages,
levelConfig,
setLocalData,
Expand Down Expand Up @@ -602,7 +603,14 @@ const Assesment = ({ discoverStart }) => {
})();
} else {
(async () => {
const virtualId = getLocalData("virtualId");
let virtualId;

if (getParameter("virtualId", window.location.search)) {
virtualId = getParameter("virtualId", window.location.search);
} else {
virtualId = localStorage.getItem("virtualId");
}
localStorage.setItem("virtualId", virtualId);
const language = lang;
const getMilestoneDetails = await axios.get(
`${process.env.REACT_APP_LEARNER_AI_APP_HOST}/${config.URLS.GET_MILESTONE}/${virtualId}?language=${language}`
Expand Down
2 changes: 1 addition & 1 deletion src/components/Mechanism/WordsOrImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const WordsOrImage = ({
lineHeight: "50px",
}}
>
{words || ""}
{words ? words[0].toUpperCase() + words.slice(1) : ""}
</Typography>
)}
{matchedChar && (
Expand Down
7 changes: 7 additions & 0 deletions src/utils/constants.js

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

10 changes: 9 additions & 1 deletion src/views/AppContent/AppContent.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import React, { useEffect, Fragment } from "react";
import { Routes, Route, useNavigate } from "react-router-dom";
import CustomizedSnackbars from "../../views/Snackbar/CustomSnackbar";
import { getParameter } from "../../utils/constants";

const PrivateRoute = (props) => {
const virtualId = localStorage.getItem('virtualId');
let virtualId;

if (getParameter("virtualId", window.location.search)) {
virtualId = getParameter("virtualId", window.location.search);
} else {
virtualId = localStorage.getItem("virtualId");
}

const navigate = useNavigate();
useEffect(() => {
if (!virtualId && props.requiresAuth) {
Expand Down

0 comments on commit f77e5b4

Please sign in to comment.