]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Contact/Profile.php
Apply suggestions from code review
[friendica.git] / src / Module / Contact / Profile.php
index 736761f88292b593863612b46515696120027b2a..15eebd3603830befa539acfd8a98f2407922bef7 100644 (file)
@@ -197,7 +197,23 @@ class Profile extends BaseModule
                                        Contact\User::setIgnored($contact['id'], DI::userSession()->getLocalUserId(), true);
                                        $message = $this->t('Contact has been ignored');
                                }
+       
+                               // @TODO: add $this->localRelationship->save($localRelationship);
+                               DI::sysmsg()->addInfo($message);
+                       }
+
+                       if ($cmd === 'collapse') {
+                               if ($localRelationship->collapsed) {
+                                       // @TODO Backward compatibility, replace with $localRelationship->unblock()
+                                       Contact\User::setCollapsed($contact['id'], DI::userSession()->getLocalUserId(), false);
 
+                                       $message = $this->t('Contact has been uncollapsed');
+                               } else {
+                                       // @TODO Backward compatibility, replace with $localRelationship->block()
+                                       Contact\User::setCollapsed($contact['id'], DI::userSession()->getLocalUserId(), true);
+                                       $message = $this->t('Contact has been collapsed');
+                               }
+                                       
                                // @TODO: add $this->localRelationship->save($localRelationship);
                                DI::sysmsg()->addInfo($message);
                        }
@@ -352,6 +368,7 @@ class Profile extends BaseModule
                        '$cinfo'                     => ['info', '', $localRelationship->info, ''],
                        '$blocked'                   => ($contact['blocked'] ? $this->t('Currently blocked') : ''),
                        '$ignored'                   => ($contact['readonly'] ? $this->t('Currently ignored') : ''),
+                       '$collapsed'                 => (Contact\User::isCollapsed($contact['id'], DI::userSession()->getLocalUserId()) ? $this->t('Currently collapsed') : ''),
                        '$archived'                  => ($contact['archive'] ? $this->t('Currently archived') : ''),
                        '$pending'                   => ($contact['pending'] ? $this->t('Awaiting connection acknowledge') : ''),
                        '$hidden'                    => ['hidden', $this->t('Hide this contact from others'), $localRelationship->hidden, $this->t('Replies/likes to your public posts <strong>may</strong> still be visible')],
@@ -479,6 +496,14 @@ class Profile extends BaseModule
                        'id'    => 'toggle-ignore',
                ];
 
+               $contact_actions['collapse'] = [
+                       'label' => $localRelationship->collapsed ? $this->t('Uncollapse') : $this->t('Collapse'),
+                       'url'   => 'contact/' . $contact['id'] . '/collapse?t=' . $formSecurityToken,
+                       'title' => $this->t('Toggle Collapsed status'),
+                       'sel'   => $localRelationship->collapsed ? 'active' : '',
+                       'id'    => 'toggle-collapse',
+               ];
+
                if (Protocol::supportsRevokeFollow($contact['network']) && in_array($localRelationship->rel, [Contact::FOLLOWER, Contact::FRIEND])) {
                        $contact_actions['revoke_follow'] = [
                                'label' => $this->t('Revoke Follow'),