Merge pull request #10361 from annando/limit-context

Simplify the code
This commit is contained in:
Hypolite Petovan 2021-06-02 09:11:11 -04:00 committed by GitHub
commit 86d56c7f57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,22 +72,18 @@ class Context extends BaseApi
$statuses = ['ancestors' => [], 'descendants' => []];
$ancestors = [];
foreach (self::getParents($id, $parents) as $ancestor) {
$ancestors[] = $ancestor;
}
$ancestors = self::getParents($id, $parents);
asort($ancestors);
foreach (array_slice($ancestors, 0, $request['limit']) as $ancestor) {
$statuses['ancestors'][] = DI::mstdnStatus()->createFromUriId($ancestor, $uid);;
}
$descendants = [];
foreach (self::getChildren($id, $children) as $descendant) {
$descendants[] = $descendant;
}
$descendants = self::getChildren($id, $children);
asort($descendants);
foreach (array_slice($descendants, 0, $request['limit']) as $descendant) {
$statuses['descendants'][] = DI::mstdnStatus()->createFromUriId($descendant, $uid);
}