From 4d19a6f0e3580af6cc57128927b1c6bbbca09c27 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 2 Jun 2021 07:15:42 +0000 Subject: [PATCH] Simplify the code --- src/Module/Api/Mastodon/Statuses/Context.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Module/Api/Mastodon/Statuses/Context.php b/src/Module/Api/Mastodon/Statuses/Context.php index afa42f7b40..112ae857c6 100644 --- a/src/Module/Api/Mastodon/Statuses/Context.php +++ b/src/Module/Api/Mastodon/Statuses/Context.php @@ -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); }