distribute posts evenly, kinda like zip function in python
regular sorting wasn't working unfortunately :/
This commit is contained in:
parent
976f27680a
commit
83a488c134
|
@ -1,3 +1,5 @@
|
|||
import 'dart:math' show max;
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
@ -229,10 +231,17 @@ class InfiniteHomeList extends HookWidget {
|
|||
limit: limit,
|
||||
auth: accStore.defaultTokenFor(instanceUrl)?.raw,
|
||||
));
|
||||
final posts =
|
||||
await Future.wait(futures).then((value) => value.expand((e) => e));
|
||||
// TODO: sorting
|
||||
return posts.toList(); // .sort();
|
||||
final posts = (await Future.wait(futures));
|
||||
final newPosts = <PostView>[];
|
||||
for (final i
|
||||
in Iterable.generate(posts.map((e) => e.length).reduce(max))) {
|
||||
for (final el in posts) {
|
||||
if (el.elementAt(i) != null) {
|
||||
newPosts.add(el[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newPosts;
|
||||
}
|
||||
|
||||
Future<List<PostView>> Function(int, int) _fetcherFromInstance(
|
||||
|
|
Loading…
Reference in New Issue