]> git.mxchange.org Git - friendica.git/commitdiff
Correctly initialize post actions button template variable
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 14 Feb 2020 01:42:15 +0000 (20:42 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Fri, 14 Feb 2020 01:42:15 +0000 (20:42 -0500)
- Address https://github.com/friendica/friendica/issues/7999#issuecomment-586020764

include/conversation.php
src/Object/Post.php

index 3707962576af422c2e84431b444c8e1ea200cb16..7d0ec0b724566c72d003aa392946a605956c5c70 100644 (file)
@@ -673,7 +673,11 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                                $isstarred = "unstarred";
 
                                $lock = false;
-                               $likebuttons = false;
+                               $likebuttons = [
+                                       'like'    => null,
+                                       'dislike' => null,
+                                       'share'   => null,
+                               ];
 
                                $body = Item::prepareBody($item, true, $preview);
 
index 7b8f4b00d6b2ce4879bc735cc1f9898f08b1afaa..31cbe7a7e10f51e13e791e73c77e01c3280fb61e 100644 (file)
@@ -151,7 +151,11 @@ class Post
                        ];
                }
                $sparkle = '';
-               $buttons = '';
+               $buttons = [
+                       'like'    => null,
+                       'dislike' => null,
+                       'share'   => null,
+               ];
                $dropping = false;
                $pinned = '';
                $pin = false;
@@ -337,10 +341,8 @@ class Post
                }
 
                if ($conv->isWritable()) {
-                       $buttons = [
-                               'like'    => [DI::l10n()->t("I like this \x28toggle\x29"), DI::l10n()->t("like")],
-                               'dislike' => [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")],
-                       ];
+                       $buttons['like']    = [DI::l10n()->t("I like this \x28toggle\x29")      , DI::l10n()->t("like")];
+                       $buttons['dislike'] = [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")];
                        if ($shareable) {
                                $buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')];
                        }
@@ -372,18 +374,14 @@ class Post
                $owner_name_e = $this->getOwnerName();
 
                // Disable features that aren't available in several networks
-               if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
-                       unset($buttons["dislike"]);
+               if ($buttons["dislike"] && !in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
+                       $buttons["dislike"] = false;
                        $isevent = false;
                        $tagger = '';
                }
 
-               if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
-                       unset($buttons["like"]);
-               }
-
-               if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
-                       unset($buttons["like"]);
+               if ($buttons["like"] && in_array($item["network"], [Protocol::FEED, Protocol::MAIL])) {
+                       $buttons["like"] = false;
                }
 
                $tags = Term::populateTagsFromItem($item);