Skip to content

Commit

Permalink
修复收藏夹超过20个后似乎将无法加载 (#228) (#235)
Browse files Browse the repository at this point in the history
Co-authored-by: colin <[email protected]>
  • Loading branch information
zansbang and colin authored Jan 15, 2024
1 parent 5facc3c commit 9e11d13
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/Libs/Libs.Adapter/FavoriteAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,39 @@ public static VideoFavoriteView ConvertToVideoFavoriteView(VideoFavoriteGalleryR
.Select(ConvertToVideoFavoriteFolderGroup);
return new VideoFavoriteView(favoriteSets, defaultFolder);
}

/// <summary>
/// 将视频收藏夹概览响应 <see cref="VideoFavoriteGalleryResponse"/> 转换为视频收藏视图.
/// </summary>
/// <param name="response">视频收藏夹概览响应.</param>
/// <returns><see cref="VideoFavoriteView"/>.</returns>
public static VideoFavoriteView ConvertToVideoFavoriteView(VideoFavoriteGalleryResponse response, FavoriteListResponse listData)
{
var defaultFolder = ConvertToVideoFavoriteFolderDetail(response.DefaultFavoriteList);

var mineCreateFav = response.FavoriteFolderList.Find(ff => ff.Id == 1);
mineCreateFav.MediaList.List = listData.List.Where(fm => fm.Title != "默认收藏夹").Select(FavoriteAdapter.ConvertToVideoFavoriteListDetail).ToList();

// 过滤稍后再看的内容,稍后再看列表的Id为3.
var favoriteSets = response.FavoriteFolderList?
.Where(p => p.Id != 3)
.Select(ConvertToVideoFavoriteFolderGroup);
return new VideoFavoriteView(favoriteSets, defaultFolder);
}

/// <summary>
/// 将收藏夹元数据转为收藏夹详情.
/// </summary>
/// <param name="favoriteMetas">收藏夹元数据.</param>
/// <returns>收藏夹详情.</returns>
public static FavoriteListDetail ConvertToVideoFavoriteListDetail(FavoriteMeta favoriteMetas)
{
var favoriteListDetail = new FavoriteListDetail();
favoriteListDetail.Title = favoriteMetas.Title;
favoriteListDetail.Id = favoriteMetas.Id;
favoriteListDetail.OriginId = favoriteMetas.FolderId;
favoriteListDetail.Mid = favoriteMetas.UserId;
favoriteListDetail.MediaCount = favoriteMetas.MediaCount;
return favoriteListDetail;
}
}
13 changes: 12 additions & 1 deletion src/Libs/Libs.Provider/FavoriteProvider/FavoriteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,18 @@ public async Task<VideoFavoriteView> GetVideoFavoriteViewAsync(string userId)
var result = await HttpProvider.ParseAsync<ServerResponse<VideoFavoriteGalleryResponse>>(response);
_videoCollectFolderPageNumber = 1;
_videoCreatedFolderPageNumber = 1;
return FavoriteAdapter.ConvertToVideoFavoriteView(result.Data);

queryParameters = new Dictionary<string, string>
{
{ Query.UpId, userId.ToString() },
{ Query.Type, "2" },
};
request = await HttpProvider.GetRequestMessageAsync(HttpMethod.Get, Account.FavoriteList, queryParameters, needToken: true);
response = await HttpProvider.Instance.SendAsync(request);
var resultList = await HttpProvider.ParseAsync<ServerResponse<FavoriteListResponse>>(response);
var listData = resultList.Data;

return FavoriteAdapter.ConvertToVideoFavoriteView(result.Data, listData);
}

/// <summary>
Expand Down

0 comments on commit 9e11d13

Please sign in to comment.