Repository navigation
Conversation
Summary of ChangesHello @kazukokawagawa, 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! This pull request significantly upgrades the application's download system, focusing on reliability, performance, and user control. Key improvements include enabling concurrent downloads, ensuring download tasks persist across application restarts, and providing a mechanism to cancel ongoing downloads. These changes aim to deliver a more stable and user-friendly download experience. Highlights
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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-executed refactoring of the download management system. Key improvements include support for concurrent downloads, download cancellation, and robust state restoration on application startup. The code has been made more modular and readable, particularly by extracting the complex lyric processing logic into a separate method. My review focuses on further improving type safety and streamlining some of the new logic for better maintainability.
| const item = downloadItems.get(songId); | ||
| if (item) { | ||
| item.cancel(); | ||
| downloadItems.delete(songId); |
There was a problem hiding this comment.
The downloadItems.delete(songId) call here is redundant. The finally block in the download-file handler already ensures that the item is deleted from downloadItems after the download completes, fails, or is cancelled. Removing this line will centralize the cleanup logic and prevent potential confusion. The item.cancel() call will cause the download() promise to reject, which will trigger the finally block in download-file.
| // 1. 重置下载中状态为等待中 (应用重启后的恢复) | ||
| dataStore.downloadingSongs.forEach((item) => { | ||
| if (item.status === "downloading") { | ||
| dataStore.updateDownloadStatus(item.song.id, "waiting"); | ||
| dataStore.updateDownloadProgress(item.song.id, 0, "0MB", "0MB"); | ||
| } | ||
| }); | ||
|
|
||
| // 2. 将等待中的任务加入队列 | ||
| dataStore.downloadingSongs.forEach((item) => { | ||
| if (item.status === "waiting") { | ||
| const isQueued = this.queue.some((t) => t.song.id === item.song.id); | ||
| const isActive = this.activeDownloads.has(item.song.id); | ||
|
|
||
| if (!isQueued && !isActive) { | ||
| this.queue.push({ song: item.song, quality: item.quality }); | ||
| } | ||
| } | ||
| }); |
There was a problem hiding this comment.
The init method currently iterates over dataStore.downloadingSongs twice. This can be optimized by combining the two loops into one. This improves both performance and readability by processing each item in a single pass.
// 1. 重置下载中状态为等待中 (应用重启后的恢复) 并加入队列
dataStore.downloadingSongs.forEach((item) => {
let isWaiting = item.status === "waiting";
if (item.status === "downloading") {
dataStore.updateDownloadStatus(item.song.id, "waiting");
dataStore.updateDownloadProgress(item.song.id, 0, "0MB", "0MB");
isWaiting = true;
}
if (isWaiting) {
const isQueued = this.queue.some((t) => t.song.id === item.song.id);
const isActive = this.activeDownloads.has(item.song.id);
if (!isQueued && !isActive) {
this.queue.push({ song: item.song, quality: item.quality });
}
}
});| } catch (error) { | ||
| console.error("Download failed:", error); |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
| .filter((item: any) => item.login !== "type-bot" && item.type !== "Bot") | ||
| .map((item: any) => ({ |
| this.failSkipCount++; | ||
|
|
||
| // 连续跳过 3 首直接暂停 | ||
| if (this.failSkipCount >= 3) { |
No description provided.