expandThreads method
Expand the feed and add it to the stream
Implementation
Future<void> expandThreads({
String? tag,
ThreadsSortOrder? sort,
int amount = 20,
}) async {
final key = _getThreadsKey(tag, sort?.name);
if (!_feedStreamControllers.containsKey(key)) {
throw NotFoundFailure('Threads $key not found');
}
final curFeed = _feedStreamControllers[key]!.value;
unawaited(
_fetchAndAddFeed(
tag: tag,
sort: sort?.toFeedSortOrder(),
start: 0, // FIXME Only get the items to expand
// start: curFeed.length >= 2 ? curFeed.length - 2 : 0,
limit: curFeed.length + amount,
isThreads: true,
),
);
// var lastDuplicate = feed.posts.indexOf(newFeed[0]);
// if (lastDuplicate == -1) {
// // FIXME We will miss some items if this happens; not a big deal IMHO
// lastDuplicate = feed.length;
// }
// final expandedFeed = Feed(
// tag: feedData.tag,
// sort: feedData.sort.name,
// posts: [...feed.posts.getRange(0, lastDuplicate), ...newFeed.posts]);
}