feat: update recentViews list to only keep the first 20 items (#4512)

This commit is contained in:
Lucas.Xu 2024-01-26 22:35:33 +08:00 committed by GitHub
parent ed78cb4efc
commit 72a23bfe82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,9 +25,12 @@ class _MobileRecentFolderState extends State<MobileRecentFolder> {
child: BlocBuilder<RecentViewsBloc, RecentViewsState>(
builder: (context, state) {
final ids = <String>{};
final List<ViewPB> recentViews = state.views.reversed.toList();
List<ViewPB> recentViews = state.views.reversed.toList();
recentViews.retainWhere((element) => ids.add(element.id));
// only keep the first 10 items.
// only keep the first 20 items.
recentViews = recentViews.take(20).toList();
if (recentViews.isEmpty) {
return const SizedBox.shrink();