Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All 1.3.1 dev #256

Merged
merged 12 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@mui/material": "^5.2.2",
"@mui/styles": "^5.2.3",
"@project-sunbird/client-services": "^5.1.2",
"@project-sunbird/telemetry-sdk": "0.0.29",
"@reduxjs/toolkit": "^2.2.0",
"@tekdi/all-telemetry-sdk": "^0.0.32",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
26 changes: 10 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,18 @@ import { AppContent } from "./views";
import theme from "./assets/styles/theme";
import { initialize, end } from "./services/telementryService";
import { startEvent } from "./services/callTelemetryIntract";
import "@project-sunbird/telemetry-sdk/index.js";
import "@tekdi/all-telemetry-sdk/index.js";
import { getParameter } from "./utils/constants";

const App = () => {
const ranonce = useRef(false);
useEffect(() => {
const initService = async () => {
var did;
if (localStorage.getItem("fpDetails_v2") !== null) {
let fpDetails_v2 = localStorage.getItem("fpDetails_v2");
did = fpDetails_v2.result;
} else {
did = localStorage.getItem("did");
}

const initService = async (visitorId) => {
await initialize({
context: {
mode: process.env.REACT_APP_MODE, // To identify preview used by the user to play/edit/preview
authToken: "", // Auth key to make api calls
did: did, // Unique id to identify the device or browser
did: localStorage.getItem("deviceId") || visitorId, // Unique id to identify the device or browser
uid: "anonymous",
channel: process.env.REACT_APP_CHANNEL, // Unique id of the channel(Channel ID)
env: process.env.REACT_APP_ENV,
Expand Down Expand Up @@ -63,18 +55,20 @@ const App = () => {
const fp = await FingerprintJS.load();

const { visitorId } = await fp.get();
if (!localStorage.getItem("did")) {
localStorage.setItem("did", visitorId);
}
initService();
// //if (!localStorage.getItem("did")) {
// localStorage.setItem("did", visitorId);
// //}
initService(visitorId);
};

setFp();
}, []);

useEffect(() => {
const handleBeforeUnload = (event) => {
window.telemetry && window.telemetry.syncEvents && window.telemetry.syncEvents();
window.telemetry &&
window.telemetry.syncEvents &&
window.telemetry.syncEvents();
};

// Add the event listener
Expand Down
4 changes: 4 additions & 0 deletions src/components/Practice/Mechanics3.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const Mechanics2 = ({
setOpenMessageDialog,
options,
audio,
isNextButtonCalled,
setIsNextButtonCalled
}) => {
const [words, setWords] = useState([]);
const [sentences, setSentences] = useState([]);
Expand Down Expand Up @@ -511,6 +513,8 @@ const Mechanics2 = ({
setEnableNext,
showOnlyListen: !answer?.isAns,
setOpenMessageDialog,
isNextButtonCalled,
setIsNextButtonCalled
}}
/>
</Box>
Expand Down
11 changes: 8 additions & 3 deletions src/components/Practice/Mechanics4.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const Mechanics4 = ({
loading,
setOpenMessageDialog,
audio,
isNextButtonCalled,
setIsNextButtonCalled
}) => {
const [words, setWords] = useState(
type === "word" ? [] : ["Friend", "She is", "My"]
Expand Down Expand Up @@ -215,8 +217,9 @@ const Mechanics4 = ({
paddingX: type === "word" ? 0 : "20px",
}}
>
{selectedWords?.map((elem) => (
{selectedWords?.map((elem, ind) => (
<span
key={ind}
Comment on lines +220 to +222
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use stable unique identifiers as keys instead of array indices.

Using array indices as keys in React's map function is an anti-pattern that can lead to rendering issues and inefficient updates. Consider using stable unique identifiers from the data if available.

If the elements have unique properties, use them as keys:

- {selectedWords?.map((elem, ind) => (
-   <span key={ind}
+ {selectedWords?.map((elem, ind) => (
+   <span key={`${elem}-${ind}`}

- {words?.map((elem, ind) => (
-   <React.Fragment key={ind}>
+ {words?.map((elem, ind) => (
+   <React.Fragment key={`${elem}-${ind}`}>

Also applies to: 273-274

onClick={() => handleWords(elem, true)}
className={
answer === "wrong"
Expand Down Expand Up @@ -267,8 +270,8 @@ const Mechanics4 = ({
mb: 3,
}}
>
{words?.map((elem) => (
<React.Fragment key={elem}>
{words?.map((elem, ind) => (
<React.Fragment key={ind}>
{type === "word" ? (
<Box
onClick={() => handleWords(elem)}
Expand Down Expand Up @@ -357,6 +360,8 @@ const Mechanics4 = ({
setEnableNext,
showOnlyListen: answer !== "correct",
setOpenMessageDialog,
isNextButtonCalled,
setIsNextButtonCalled,
}}
/>
</Box>
Expand Down
Loading
Loading