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 feedback change #247

Merged
merged 5 commits into from
Jan 6, 2025
Merged

Conversation

gouravmore
Copy link
Member

@gouravmore gouravmore commented Jan 6, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Implemented audio preloading mechanism across multiple components to improve performance.
    • Enhanced audio handling with custom preload hook.
  • Performance Improvements

    • Optimized audio file loading in Mechanics3, Mechanics4, and VoiceAnalyser components.
    • Reduced potential audio playback latency.
  • Bug Fixes

    • Adjusted logic for fetching pointer details based on iframe context to prevent unnecessary API calls.
  • Technical Updates

    • Updated microphone permission handling to use modern web standards.
    • Streamlined audio resource management.

These updates aim to provide a smoother and more responsive user experience with improved audio interactions.

ajinkyapandetekdi and others added 2 commits January 6, 2025 16:33
…e lost and earn], fill in the blanks and jumble the words mechanism
Issueid #232843 fix: Audio sync issue for low network - Showcase [liv…
Copy link

coderabbitai bot commented Jan 6, 2025

Caution

Review failed

The pull request is closed.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/components/Assesment/Assesment.jsx

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find the config "react-app" to extend from. Please check that the name of the config is correct.

The config "react-app" was referenced from the config file in "/package.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

The pull request introduces a custom usePreloadAudio hook across multiple components to improve audio handling. The changes are implemented in four files: Mechanics3.jsx, Mechanics4.jsx, VoiceAnalyser.js, and Assesment components. The primary modification involves replacing direct audio file path usage with preloaded audio references, which can potentially enhance performance and reduce latency during audio playback. Additionally, the VoiceAnalyser.js file updates the microphone permissions method to use a more modern API approach, while the Assesment components modify the fetching logic for pointer details based on the iframe context.

Changes

File Change Summary
src/components/Practice/Mechanics3.jsx Added preloaded audio variables for correct, wrong, and remove sounds using usePreloadAudio hook
src/components/Practice/Mechanics4.jsx Introduced preloaded audio variables for correct, wrong, add, and remove sounds using usePreloadAudio hook
src/utils/VoiceAnalyser.js Added preloaded audio variables for lives add and cut sounds, updated microphone permissions method
src/components/Assesment/Assesment.jsx Modified pointer details fetching logic to check for iframe context before API calls
src/components/AssesmentEnd/AssesmentEnd.jsx Updated pointer details fetching logic to conditionally execute based on iframe context
src/views/Practice/Practice.jsx Adjusted pointer details fetching in fetchDetails function to check for iframe context before API call

Possibly related PRs


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7795733 and c1e540e.

📒 Files selected for processing (3)
  • src/components/Assesment/Assesment.jsx (2 hunks)
  • src/components/AssesmentEnd/AssesmentEnd.jsx (1 hunks)
  • src/views/Practice/Practice.jsx (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
src/components/Practice/Mechanics4.jsx (2)

122-122: Potential redundancy in constructing the Audio object
Since each variable (e.g., removeSoundAudio) is already an audio object returned by usePreloadAudio, creating a new Audio(...) with that same reference could lead to re-downloading or re-initializing audio. You can simplify and directly call removeSoundAudio.play() without using the new Audio(...) constructor.

- let audio = new Audio(isSelected ? removeSoundAudio : addSoundAudio);
- audio.play();
+ (isSelected ? removeSoundAudio : addSoundAudio).play();

142-143: Avoid repeated new Audio instantiation
As with line 122, you can use the preloaded audio references directly instead of passing them to new Audio(...).

-let audio = new Audio(
-  [...selectedWords, word]?.join(" ") === parentWords
-    ? correctSoundAudio
-    : wrongSoundAudio
-);
-audio.play();
+[...selectedWords, word]?.join(" ") === parentWords
+  ? correctSoundAudio.play()
+  : wrongSoundAudio.play();
src/components/Practice/Mechanics3.jsx (2)

92-92: Redundant usage of new Audio with a preloaded reference
Similar to the pattern in Mechanics4, you can directly play the preloaded audio reference:

- let audio = new Audio(isSoundCorrect ? correctSoundAudio : wrongSoundAudio);
- audio.play();
+ (isSoundCorrect ? correctSoundAudio : wrongSoundAudio).play();

104-104: Directly call .play() on the preloaded audio
As above, skip re-instantiating the same audio content via new Audio(...) and call .play() directly.

- let audio = new Audio(removeSoundAudio);
- audio.play();
+ removeSoundAudio.play();
src/utils/VoiceAnalyser.js (1)

634-634: Refactor to avoid double initialization
You might streamline the audio logic by invoking .play() directly on isLiveLost ? livesCutAudio : livesAddAudio rather than wrapping the reference again with new Audio(...).

- const audio = new Audio(isLiveLost ? livesCutAudio : livesAddAudio);
- audio.play();
+ (isLiveLost ? livesCutAudio : livesAddAudio).play();
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f23c9a7 and 7e0e930.

📒 Files selected for processing (3)
  • src/components/Practice/Mechanics3.jsx (4 hunks)
  • src/components/Practice/Mechanics4.jsx (4 hunks)
  • src/utils/VoiceAnalyser.js (3 hunks)
🔇 Additional comments (6)
src/components/Practice/Mechanics4.jsx (2)

16-16: Imported custom hook looks good
The usage of the usePreloadAudio hook import is consistent with the changes below. No issues found.


55-58: Good use of usePreloadAudio for performance
Preloading audio files can help reduce latency when playing sounds at runtime. This is a neat improvement. Consider verifying that the audio files are small enough not to adversely impact page load performance.

src/components/Practice/Mechanics3.jsx (2)

21-21: New hook import for audio preloading
This import statement is consistent with the project’s new pattern for better audio handling. No objections.


68-70: Preloaded audio references introduced
Allocating references for correct, wrong, and remove sounds via the custom hook is a solid approach to reduce runtime audio load delays.

src/utils/VoiceAnalyser.js (2)

36-36: Custom hook import is consistent
Prefetching audio for lives management aligns with the new pattern used in Mechanics3 and Mechanics4.


81-82: Excellent approach to preload synergy
Preloading livesAdd and livesCut is a good optimization to ensure quick feedback on life changes.

ajinkyapandetekdi and others added 2 commits January 6, 2025 16:54
Issueid #232821 fix: Unexpected API Call: /pointer/getPoints/43477152…
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/components/AssesmentEnd/AssesmentEnd.jsx (1)

51-56: Consider adding error handling and reusability for pointer fetching.

You're conditionally fetching pointer details only if not in iframe, which is good for avoiding unnecessary requests. However, there's no try/catch block in this snippet, and no fallback if the environment variable is missing or incorrectly set. Also, this pointer-fetch logic repeats across multiple files. Extracting it into a shared helper could improve maintainability.

Here’s an example snippet adding basic error handling within these lines:

51       if (process.env.REACT_APP_IS_APP_IFRAME !== "true") {
52 +       try {
53         const getPointersDetails = await axios.get(
54           `${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
55         );
56         setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);
+       } catch (error) {
+         console.error('Error fetching pointer details:', error);
+       }
57       }
src/components/Assesment/Assesment.jsx (1)

601-606: Add error handling for pointer fetching and consider a helper function.

Similar to AssesmentEnd.jsx, you might wrap this block in a try/catch to gracefully handle network failures. If you plan to reuse this pointer-fetch logic across files, consider centralizing it in a shared utility.

601       if (process.env.REACT_APP_IS_APP_IFRAME !== "true") {
602 +       try {
603         const getPointersDetails = await axios.get(
604           `${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${usernameDetails?.data?.result?.virtualID}/${session_id}?language=${lang}`
605         );
606         setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);
+       } catch (error) {
+         console.error('Error fetching pointer details:', error);
+       }
607       }
src/views/Practice/Practice.jsx (1)

455-462: Refine pointer fetching with error handling, and centralize repeated logic.

The environment-based check is a clean way to prevent calls within an iframe. However, ensure you handle request failures. This block appears across multiple files; consider moving it into a reusable utility to keep your code DRY.

455       if (process.env.REACT_APP_IS_APP_IFRAME !== "true") {
456 +       try {
457         const getPointersDetails = await axios.get(
458           `${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.GET_POINTER}/${virtualId}/${sessionId}?language=${lang}`
459         );
460         // TODO: Just Opss icon - we are trying to fetch the score for you
461         setPoints(getPointersDetails?.data?.result?.totalLanguagePoints || 0);
+       } catch (error) {
+         console.error('Error fetching pointer details:', error);
+       }
462       }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e0e930 and 7795733.

📒 Files selected for processing (3)
  • src/components/Assesment/Assesment.jsx (2 hunks)
  • src/components/AssesmentEnd/AssesmentEnd.jsx (1 hunks)
  • src/views/Practice/Practice.jsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: deploy
🔇 Additional comments (1)
src/components/Assesment/Assesment.jsx (1)

639-639: Include error handling or a fallback for missing virtualId.

When virtualId is undefined, this check won't fetch pointer details. Ensure the rest of the code can gracefully handle that scenario. Also consider a try/catch for the subsequent operations.

@gouravmore gouravmore merged commit 2db6ecc into all-1.3.1-dev Jan 6, 2025
1 check passed
Copy link

sonarqubecloud bot commented Jan 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants