]> git.mxchange.org Git - friendica.git/commitdiff
Fix counter for emoji reactions
authorMichael <heluecht@pirati.ca>
Wed, 18 Sep 2024 20:25:51 +0000 (20:25 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 18 Sep 2024 20:49:30 +0000 (20:49 +0000)
src/Content/Conversation.php
src/Model/Post/Counts.php

index e5b5be48c5437ffb819a5f5e7553376c867acd9d..807fb6c0b1f2f5f4bfdff79218a7f7a07f374e03 100644 (file)
@@ -1018,18 +1018,18 @@ class Conversation
                }
 
                // @todo The following code should be removed, once that we display activity authors on demand 
-               $activity_emoji = [
-                       Activity::LIKE        => '👍',
-                       Activity::DISLIKE     => '👎',
-                       Activity::ATTEND      => '✔️',
-                       Activity::ATTENDMAYBE => '❓',
-                       Activity::ATTENDNO    => '❌',
-                       Activity::ANNOUNCE    => '♻',
-                       Activity::VIEW        => '📺',
-                       Activity::READ        => '📖',
+               $activity_verbs = [
+                       Activity::LIKE,
+                       Activity::DISLIKE,
+                       Activity::ATTEND,
+                       Activity::ATTENDMAYBE,
+                       Activity::ATTENDNO,
+                       Activity::ANNOUNCE,
+                       Activity::VIEW,
+                       Activity::READ,
                ];
 
-               $verbs     = array_merge(array_keys($activity_emoji), [Activity::EMOJIREACT, Activity::POST]);
+               $verbs     = array_merge($activity_verbs, [Activity::EMOJIREACT, Activity::POST]);
                $condition = DBA::mergeConditions(['parent-uri-id' => $uriids, 'gravity' => [ItemModel::GRAVITY_ACTIVITY, ItemModel::GRAVITY_COMMENT], 'verb' => $verbs], ["NOT `deleted`"]);
                $separator = chr(255) . chr(255) . chr(255);
 
@@ -1038,7 +1038,7 @@ class Conversation
                $rows = DBA::p($sql, $condition);
                while ($row = DBA::fetch($rows)) {
                        if ($row['gravity'] == ItemModel::GRAVITY_ACTIVITY) {
-                               $emoji = $row['body'] ?: $activity_emoji[$row['verb']];
+                               $emoji = $row['body'] ?: $row['verb'];
                        } else {
                                $emoji = '';
                        }
index 0f069469ba0c3204ae81b12774fbdc27de619775..3d971a5757451209ae50e2e41c46308d95aca2b1 100644 (file)
@@ -82,18 +82,18 @@ class Counts
        {
                $counts = [];
 
-               $activity_emoji = [
-                       Activity::LIKE        => '👍',
-                       Activity::DISLIKE     => '👎',
-                       Activity::ATTEND      => '✔️',
-                       Activity::ATTENDMAYBE => '❓',
-                       Activity::ATTENDNO    => '❌',
-                       Activity::ANNOUNCE    => '♻',
-                       Activity::VIEW        => '📺',
-                       Activity::READ        => '📖',
+               $activity_verbs = [
+                       Activity::LIKE,
+                       Activity::DISLIKE,
+                       Activity::ATTEND,
+                       Activity::ATTENDMAYBE,
+                       Activity::ATTENDNO,
+                       Activity::ANNOUNCE,
+                       Activity::VIEW,
+                       Activity::READ,
                ];
 
-               $verbs = array_merge(array_keys($activity_emoji), [Activity::EMOJIREACT, Activity::POST]);
+               $verbs = array_merge($activity_verbs, [Activity::EMOJIREACT, Activity::POST]);
 
                $condition  = DBA::mergeConditions($condition, ['verb' => $verbs]);
                $countquery = DBA::select('post-counts-view', [], $condition);
@@ -101,8 +101,8 @@ class Counts
                        if (!empty($count['reaction'])) {
                                $count['verb'] = Activity::EMOJIREACT;
                                $count['vid']  = Verb::getID($count['verb']);
-                       } elseif (!empty($activity_emoji[$count['verb']])) {
-                               $count['reaction'] = $activity_emoji[$count['verb']];
+                       } elseif (in_array($count['verb'], $activity_verbs)) {
+                               $count['reaction'] = $count['verb'];
                        }
                        $counts[] = $count;
                }