]> git.mxchange.org Git - friendica.git/commitdiff
Remove unused conversation response code
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 23 Feb 2020 01:41:12 +0000 (20:41 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 23 Feb 2020 01:41:12 +0000 (20:41 -0500)
- Remove get_responses()
- Remove get_response_button_text()
- Remove title key from $conv_responses array
- Address https://github.com/friendica/friendica/issues/8000#issuecomment-589263329

include/conversation.php
mod/photos.php
src/Object/Post.php
src/Object/Thread.php

index f29e6d32540f2da89f55f7e9e459173ce91c0717..02b1b7340a83e6eb8ba39b5b2080282b443b1938 100644 (file)
@@ -579,12 +579,11 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
        $items = $cb['items'];
 
        $conv_responses = [
-               'like' => ['title' => DI::l10n()->t('Likes','title')],
-               'dislike' => ['title' => DI::l10n()->t('Dislikes','title')],
-               'attendyes' => ['title' => DI::l10n()->t('Attending','title')],
-               'attendno' => ['title' => DI::l10n()->t('Not attending','title')],
-               'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')],
-               'announce' => ['title' => DI::l10n()->t('Reshares','title')]
+               'like'        => [],
+               'dislike'     => [],
+               'attendyes'   => [],
+               'attendno'    => [],
+               'attendmaybe' => []
        ];
 
        if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
@@ -1572,56 +1571,3 @@ function render_location_dummy(array $item) {
                return $item['coord'];
        }
 }
-
-function get_responses(array $conv_responses, array $response_verbs, array $item, Post $ob = null) {
-       $ret = [];
-       foreach ($response_verbs as $v) {
-               $ret[$v] = [];
-               $ret[$v]['count'] = $conv_responses[$v][$item['uri']] ?? 0;
-               $ret[$v]['list']  = $conv_responses[$v][$item['uri'] . '-l'] ?? [];
-               $ret[$v]['self']  = $conv_responses[$v][$item['uri'] . '-self'] ?? '0';
-               if (count($ret[$v]['list']) > MAX_LIKERS) {
-                       $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
-                       array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
-                               . (($ob) ? $ob->getId() : $item['id']) . '"><b>' . DI::l10n()->t('View all') . '</b></a>');
-               } else {
-                       $ret[$v]['list_part'] = '';
-               }
-               $ret[$v]['button'] = get_response_button_text($v, $ret[$v]['count']);
-               $ret[$v]['title'] = $conv_responses[$v]['title'];
-       }
-
-       $count = 0;
-       foreach ($ret as $key) {
-               if ($key['count'] == true) {
-                       $count++;
-               }
-       }
-       $ret['count'] = $count;
-
-       return $ret;
-}
-
-function get_response_button_text($v, $count)
-{
-       $return = '';
-       switch ($v) {
-               case 'like':
-                       $return = DI::l10n()->tt('Like', 'Likes', $count);
-                       break;
-               case 'dislike':
-                       $return = DI::l10n()->tt('Dislike', 'Dislikes', $count);
-                       break;
-               case 'attendyes':
-                       $return = DI::l10n()->tt('Attending', 'Attending', $count);
-                       break;
-               case 'attendno':
-                       $return = DI::l10n()->tt('Not Attending', 'Not Attending', $count);
-                       break;
-               case 'attendmaybe':
-                       $return = DI::l10n()->tt('Undecided', 'Undecided', $count);
-                       break;
-       }
-
-       return $return;
-}
index 3f959a6c2ffc102ebbbd4f0bcfafceaa02d6419c..0c94471c0453ac1e8e436abb72fbee05be82c9dc 100644 (file)
@@ -1412,11 +1412,11 @@ function photos_content(App $a)
                        }
 
                        $conv_responses = [
-                               'like'        => ['title' => DI::l10n()->t('Likes','title')],
-                               'dislike'     => ['title' => DI::l10n()->t('Dislikes','title')],
-                               'attendyes'   => ['title' => DI::l10n()->t('Attending','title')],
-                               'attendno'    => ['title' => DI::l10n()->t('Not attending','title')],
-                               'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')]
+                               'like'        => [],
+                               'dislike'     => [],
+                               'attendyes'   => [],
+                               'attendno'    => [],
+                               'attendmaybe' => []
                        ];
 
                        if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
index c92c5a32bb123aa55373e146f6eb42384330e41d..384c88a6d91aa035518935d8530bab821ad936cd 100644 (file)
@@ -272,10 +272,12 @@ class Post
                        }
                }
 
-               $responses = get_responses($conv_responses, $response_verbs, $item, $this);
-
-               foreach ($response_verbs as $value => $verbs) {
-                       $responses[$verbs]['output'] = !empty($conv_responses[$verbs][$item['uri']]) ? format_like($conv_responses[$verbs][$item['uri']], $conv_responses[$verbs][$item['uri'] . '-l'], $verbs, $item['uri']) : '';
+               $responses = [];
+               foreach ($response_verbs as $value => $verb) {
+                       $responses[$verb] = [
+                               'self'   => $conv_responses[$verb][$item['uri'] . '-self'] ?? 0,
+                               'output' => !empty($conv_responses[$verb][$item['uri']]) ? format_like($conv_responses[$verb][$item['uri']], $conv_responses[$verb][$item['uri'] . '-l'], $verb, $item['uri']) : '',
+                       ];
                }
 
                /*
index b574e300bcf24486d4921038427f4fc83dbf5ef3..f62b14c71e665ef9bb996d5a9e376ad12e118cec 100644 (file)
@@ -34,6 +34,7 @@ use Friendica\Util\Security;
  */
 class Thread
 {
+       /** @var Post[] */
        private $parents = [];
        private $mode = null;
        private $writable = false;