Skip to content

Commit

Permalink
Deduplicate UsedFor with same value for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sandreae committed Oct 18, 2023
1 parent 3737776 commit f618786
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class _PaginationUsedForTagListState extends State<PaginationUsedForTagList> {
return this._emptyResult(context);
}

var seen = Set<String>();
List<UsedFor> uniqueUses = data.documents
.where((usedFor) => seen.add(usedFor.usedFor))
.toList();

return Material(
color: MeliColors.white,
shape: const RoundedRectangleBorder(
Expand All @@ -146,7 +151,7 @@ class _PaginationUsedForTagListState extends State<PaginationUsedForTagList> {
child: SingleChildScrollView(
controller: scrollController,
child: Wrap(children: [
...this.widget.itemsBuilder(data.documents),
...this.widget.itemsBuilder(uniqueUses),
if (data.hasNextPage)
this._loadMore(context, result.isLoading, onLoadMore: () {
fetchMore!(opts);
Expand Down

0 comments on commit f618786

Please sign in to comment.