From e0d992f4529facac0c100a6325c73ab7529d4905 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Nov 2023 21:45:02 +0000 Subject: [PATCH] Display the total emoji activity --- src/Content/Conversation.php | 12 +++++++----- src/Object/Post.php | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index 66654aab10..517a364b6e 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -251,19 +251,21 @@ class Conversation /** * Format the activity text for an item/photo/video * - * @param array $links = array of pre-linked names of actors - * @param string $verb = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe' - * @param int $id = item id + * @param array $links array of pre-linked names of actors + * @param string $verb one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe' + * @param int $id item id + * @param string $activity Activity URI + * @param array $emojis Array with emoji reactions * @return string formatted text * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function formatActivity(array $links, string $verb, int $id): string + public function formatActivity(array $links, string $verb, int $id, string $activity, array $emojis): string { $this->profiler->startRecording('rendering'); $expanded = ''; $phrase = $this->getLikerPhrase($verb, $links); - $total = count($links); + $total = max(count($links), $emojis[$activity]['total'] ?? 0); if ($total > 1) { $spanatts = "class=\"btn btn-link fakelink\" onclick=\"openClose('{$verb}list-$id');\""; diff --git a/src/Object/Post.php b/src/Object/Post.php index e6aae2f5d5..d52a05dddc 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -351,7 +351,7 @@ class Post foreach ($response_verbs as $value => $verb) { $responses[$verb] = [ 'self' => $conv_responses[$verb][$item['uri-id']]['self'] ?? 0, - 'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? DI::conversation()->formatActivity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '', + 'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? DI::conversation()->formatActivity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id'], $verbs[$verb], $emojis) : '', 'total' => $emojis[$verbs[$verb]]['total'] ?? '', 'title' => $emojis[$verbs[$verb]]['title'] ?? '', ]; -- 2.39.5