mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-05 08:40:12 +08:00
@@ -2,23 +2,27 @@ import 'package:PiliPlus/models_new/search/search_rcmd/data.dart';
|
||||
import 'package:PiliPlus/models_new/search/search_trending/list.dart';
|
||||
|
||||
class SearchTrendingData extends SearchRcmdData {
|
||||
List<SearchTrendingItemModel>? topList;
|
||||
late int topCount;
|
||||
|
||||
SearchTrendingData({super.list, this.topList});
|
||||
|
||||
factory SearchTrendingData.fromJson(Map<String, dynamic> json) =>
|
||||
SearchTrendingData(
|
||||
list: (json['list'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) =>
|
||||
SearchTrendingItemModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
topList: (json['top_list'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) =>
|
||||
SearchTrendingItemModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
SearchTrendingData.fromJson(
|
||||
Map<String, dynamic> json, {
|
||||
bool needsTop = false,
|
||||
}) {
|
||||
list = (json['list'] as List<dynamic>?)
|
||||
?.map((e) => SearchTrendingItemModel.fromJson(e))
|
||||
.toList();
|
||||
if (needsTop) {
|
||||
final topList = (json['top_list'] as List<dynamic>?)
|
||||
?.map((e) => SearchTrendingItemModel.fromJson(e))
|
||||
.toList();
|
||||
topCount = topList?.length ?? 0;
|
||||
if (topList != null && topList.isNotEmpty) {
|
||||
if (list != null) {
|
||||
list!.insertAll(0, topList);
|
||||
} else {
|
||||
list = topList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user