Fix word loop conflicts during app navigation and audio playback#208
Fix word loop conflicts during app navigation and audio playback#208
Conversation
- Integrated `stopSingleWordLoop()` into `generate()`, `buildTableAndSetupPlayback()`, and `performSearch()`. - Updated `stopPlayback()` and `startPlayingFromIndex()` to manage word loop state. - Ensured the UI stop button terminates both main playback and word loops. - Added audio conflict handling in the pronunciation popup and a global 'play' event listener to stop loops when other audio is played manually. - Fixed a conflict where cross-dialect comparison didn't stop the loop. Co-authored-by: Aiuanyu <93833368+Aiuanyu@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @Aiuanyu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取請求旨在解決單詞循環功能在應用程式導航和音頻播放過程中可能出現的衝突。透過在多種用戶互動情境下(如切換上下文、執行搜尋、啟動主播放或播放彈出音頻)明確停止單詞循環,此更新有效防止了「幽靈音頻」的播放,並確保了用戶界面(循環類別和圖標)狀態的一致性。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Deploying hakspring with
|
| Latest commit: |
0ac6833
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://61350293.hakspring.pages.dev |
| Branch Preview URL: | https://fix-word-loop-conflicts-5861.hakspring.pages.dev |
Pull Request Review: Fix word loop conflicts during app navigation and audio playbackSummaryThis PR addresses issue #207 by ensuring that the single-word loop feature is properly cleaned up when navigating away from the current context. The changes add Code Quality & Best Practices✅ Strengths
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves audio conflicts by ensuring the single-word loop is stopped during various application events like navigation, search, and other audio playback. The implementation is thorough, adding checks in multiple places within main.js to handle different scenarios. My review includes a suggestion to refactor duplicated code into a helper function for better maintainability, and another to remove a debugging console.log statement. Additionally, I've noted that several test result files have been added to the repository; these are typically excluded via .gitignore to avoid cluttering the project history.
| stopSingleWordLoop(); // 【新增】 | ||
| g_mainPlaybackIndexBeforeLoop = null; // 【新增】 |
There was a problem hiding this comment.
These two lines for resetting the single-word loop state are repeated in at least 8 other places in this file. To improve code maintainability and adhere to the DRY (Don't Repeat Yourself) principle, I recommend extracting this logic into a new helper function.
You could define a function like this, for example after the stopSingleWordLoop function definition:
function resetSingleWordLoopState() {
stopSingleWordLoop();
g_mainPlaybackIndexBeforeLoop = null;
}Then, you can replace this block and all similar occurrences with a single call: resetSingleWordLoopState();.
| stopSingleWordLoop(); // 【新增】 | |
| g_mainPlaybackIndexBeforeLoop = null; // 【新增】 | |
| resetSingleWordLoopState(); |
| event.target !== singleLoopingAudio.word && | ||
| event.target !== singleLoopingAudio.sentence | ||
| ) { | ||
| console.log('偵測到其他音檔播放,停止單詞循環。'); |
This update ensures that the single-word loop feature (the "repeat" button for individual rows) is correctly cleared when navigating away from the current context.
Specifically:
These changes prevent "ghost" audio from playing after transitions and ensure the UI state (looping classes and icons) remains consistent.
Fixes #207
PR created automatically by Jules for task 5861562139682209968 started by @Aiuanyu