Skip to content

🐞 fix: 修复收藏数据200限制#618

Merged
imsyy merged 3 commits into
SPlayer-Dev:devfrom
SUBearH:P51
Dec 8, 2025
Merged

🐞 fix: 修复收藏数据200限制#618
imsyy merged 3 commits into
SPlayer-Dev:devfrom
SUBearH:P51

Conversation

@SUBearH
Copy link
Copy Markdown
Contributor

@SUBearH SUBearH commented Dec 6, 2025

🐞 fix: 修复收藏数据200限制

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @SUBearH, 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!

此拉取请求主要目的是修复用户收藏数据(特别是MV和电台)在获取时存在的200条限制问题。通过在API层引入分页参数,并重构数据获取循环逻辑,确保应用能够完整地加载用户的所有收藏数据,从而提升用户体验和数据准确性。

Highlights

  • 收藏数据分页支持: 为用户收藏的MV和电台数据接口添加了分页参数(limit 和 offset),解决了之前数据获取的200条限制。
  • 统一数据获取逻辑: 重构了 setUserLikeDataLoop 辅助函数,使其能够循环获取所有用户收藏数据,并根据不同的数据类型(MV、电台、歌单等)灵活处理API响应。
  • 优化分页策略: 将分页限制从100调整为50,并改进了循环终止条件,确保数据完整性并提升稳定性。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

此 PR 修复了获取收藏数据时存在的数量限制问题,通过为 userMvuserDj 接口添加分页参数,并重构 setUserLikeDataLoop 函数以支持循环获取所有分页数据。整体逻辑清晰,解决了原有的问题。不过,在 setUserLikeDataLoop 函数的实现中有一些可以改进的地方,以增强代码的健壮性和可维护性。具体请看我的评论。

Comment thread src/utils/auth.ts Outdated
Comment thread src/utils/auth.ts
dataStore.setUserLikeData(key as any, allData as CoverType[]);
}

console.log(`✅ Fetched ${allData.length} ${key} for user ${userId}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

此处的 console.log 语句看起来是用于调试目的。在生产环境中,这类日志信息可能会对控制台造成不必要的干扰。建议在合并到主分支前移除此行代码。

@SUBearH SUBearH marked this pull request as ready for review December 7, 2025 08:41
Copilot AI review requested due to automatic review settings December 7, 2025 08:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a limitation where user collection data (favorites/subscriptions) was capped at 200 items. The solution implements proper pagination for DJ/radio and MV collections to fetch all user data.

Key changes:

  • Added pagination parameters (limit, offset) to userMv and userDj API functions
  • Refactored updateUserLikeDjs and updateUserLikeMvs to use the existing setUserLikeDataLoop helper
  • Modified setUserLikeDataLoop to handle different API response structures and implement more robust pagination logic with error handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/api/user.ts Added limit and offset parameters to userMv and userDj functions to support pagination
src/utils/auth.ts Refactored DJ and MV update functions to use pagination loop; enhanced setUserLikeDataLoop with better error handling and support for different API response structures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/auth.ts Outdated
Comment thread src/utils/auth.ts
Comment on lines +310 to +311
} else if (key === "playlists") {
data = result.playlist || [];
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The handling of the "playlists" key appears to be unnecessary. The setUserLikeDataLoop function is only called with keys "artists", "albums", "mvs", and "djs" (lines 173, 178, 183, 188). The "playlists" data is handled separately in updateUserLikePlaylist (line 155), which doesn't use this loop function. Consider removing this case to avoid confusion:

let data: any[] = [];
if (key === "djs") {
  data = result.djRadios || [];
} else {
  data = result.data || [];
}
Suggested change
} else if (key === "playlists") {
data = result.playlist || [];

Copilot uses AI. Check for mistakes.
Comment thread src/utils/auth.ts
// 更新偏移量
offset += limit;
canLoop = offset < count && formattedData.length > 0;
const limit = 50; // 限制每页50条
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The comment "限制每页50条" (limit to 50 items per page) could be more informative. Consider explaining why 50 was chosen instead of the previous 100. For example:

const limit = 50; // Reduced from 100 to 50 to avoid API rate limits and improve reliability
Suggested change
const limit = 50; // 限制每页50条
const limit = 50; // Reduced from 100 to 50 to avoid API rate limits and improve reliability

Copilot uses AI. Check for mistakes.
Comment thread src/utils/auth.ts
data = result.data || [];
}

if (!Array.isArray(data) || data.length === 0) {
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The check !Array.isArray(data) may not correctly handle all API responses. If the API returns a response where the expected data field is missing or null (rather than an empty array), this condition would evaluate to true and break the loop. However, this could happen on the first request, potentially leading to silent failures where no data is fetched at all.

Consider adding validation before entering the loop or providing better error messaging:

if (!Array.isArray(data)) {
  if (offset === 0) {
    console.error(`Unexpected response format for ${key}:`, result);
  }
  break;
}
if (data.length === 0) {
  break; // No more data
}
Suggested change
if (!Array.isArray(data) || data.length === 0) {
if (!Array.isArray(data)) {
if (offset === 0) {
console.error(`Unexpected response format for ${key}:`, result);
}
break;
}
if (data.length === 0) {

Copilot uses AI. Check for mistakes.
imsyy and others added 2 commits December 8, 2025 10:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@imsyy imsyy merged commit 6991557 into SPlayer-Dev:dev Dec 8, 2025
@SUBearH SUBearH deleted the P51 branch December 17, 2025 07:08
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.

3 participants