Skip to content

Commit

Permalink
fix: bookmark load pending error
Browse files Browse the repository at this point in the history
  • Loading branch information
violet-dev committed Dec 10, 2023
1 parent b9c9a3e commit e284f00
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/pages/bookmark/group/group_article_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,36 @@ class _GroupArticleListPageState extends State<GroupArticleListPage> {
final bookmark = await Bookmark.getInstance();
final articles = await bookmark.getArticle();

var cc = articles
final articleList = articles
.where((e) => e.group() == widget.groupId)
.toList()
.reversed
.toList();

if (cc.isEmpty) {
if (articleList.isEmpty) {
queryResult = <QueryResult>[];
filterResult = queryResult;
_rebuild();
return;
}

final value = await QueryManager.queryIds(
cc.map((e) => int.parse(e.article())).toList());
final queryIds = await QueryManager.queryIds(
articleList.map((e) => int.parse(e.article())).toList());

var qr = <String, QueryResult>{};
for (var element in value) {
for (var element in queryIds) {
qr[element.id().toString()] = element;
}

var result = <QueryResult>[];
for (var element in cc) {

// TODO: fix this hack
// ignore: avoid_function_literals_in_foreach_calls
articleList.forEach((element) async {
var article = qr[element.article()];
article ??= await _tryGetArticleFromHitomi(element.article());
result.add(article);
}
});

queryResult = result;
_applyFilter();
Expand Down

0 comments on commit e284f00

Please sign in to comment.