Merge pull request #8284 from MrPetovan/bug/notices

Correctly initialize post actions button template variable
This commit is contained in:
Tobias Diekershoff 2020-02-14 07:26:58 +01:00 committed by GitHub
commit fef920c66f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View file

@ -673,7 +673,11 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
$isstarred = "unstarred"; $isstarred = "unstarred";
$lock = false; $lock = false;
$likebuttons = false; $likebuttons = [
'like' => null,
'dislike' => null,
'share' => null,
];
$body = Item::prepareBody($item, true, $preview); $body = Item::prepareBody($item, true, $preview);

View file

@ -151,7 +151,11 @@ class Post
]; ];
} }
$sparkle = ''; $sparkle = '';
$buttons = ''; $buttons = [
'like' => null,
'dislike' => null,
'share' => null,
];
$dropping = false; $dropping = false;
$pinned = ''; $pinned = '';
$pin = false; $pin = false;
@ -337,10 +341,8 @@ class Post
} }
if ($conv->isWritable()) { if ($conv->isWritable()) {
$buttons = [ $buttons['like'] = [DI::l10n()->t("I like this \x28toggle\x29") , DI::l10n()->t("like")];
'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")];
'dislike' => [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")],
];
if ($shareable) { if ($shareable) {
$buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')]; $buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')];
} }
@ -372,18 +374,14 @@ class Post
$owner_name_e = $this->getOwnerName(); $owner_name_e = $this->getOwnerName();
// Disable features that aren't available in several networks // Disable features that aren't available in several networks
if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) { if ($buttons["dislike"] && !in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
unset($buttons["dislike"]); $buttons["dislike"] = false;
$isevent = false; $isevent = false;
$tagger = ''; $tagger = '';
} }
if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) { if ($buttons["like"] && in_array($item["network"], [Protocol::FEED, Protocol::MAIL])) {
unset($buttons["like"]); $buttons["like"] = false;
}
if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
unset($buttons["like"]);
} }
$tags = Term::populateTagsFromItem($item); $tags = Term::populateTagsFromItem($item);