mirror of
https://github.com/friendica/friendica
synced 2025-04-21 23:50:18 +00:00
Posts from contacts can now be collapsed
This commit is contained in:
parent
c074da2b87
commit
50e43c530e
9 changed files with 229 additions and 150 deletions
|
@ -87,6 +87,11 @@ class Contact extends BaseModule
|
|||
self::toggleIgnoreContact($cdata['public']);
|
||||
$count_actions++;
|
||||
}
|
||||
|
||||
if (!empty($_POST['contacts_batch_collapse'])) {
|
||||
self::toggleCollapseContact($cdata['public']);
|
||||
$count_actions++;
|
||||
}
|
||||
}
|
||||
if ($count_actions > 0) {
|
||||
DI::sysmsg()->addInfo(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions));
|
||||
|
@ -165,6 +170,18 @@ class Contact extends BaseModule
|
|||
Model\Contact\User::setIgnored($contact_id, DI::userSession()->getLocalUserId(), $ignored);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the collapsed status of a contact identified by id.
|
||||
*
|
||||
* @param int $contact_id Id of the contact with uid = 0
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function toggleCollapseContact(int $contact_id)
|
||||
{
|
||||
$collapsed = !Model\Contact\User::isCollapsed($contact_id, DI::userSession()->getLocalUserId());
|
||||
Model\Contact\User::setCollapsed($contact_id, DI::userSession()->getLocalUserId(), $collapsed);
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
|
@ -405,9 +422,10 @@ class Contact extends BaseModule
|
|||
'$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
|
||||
'multiselect' => 1,
|
||||
'$batch_actions' => [
|
||||
'contacts_batch_update' => DI::l10n()->t('Update'),
|
||||
'contacts_batch_block' => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
|
||||
'contacts_batch_ignore' => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
|
||||
'contacts_batch_update' => DI::l10n()->t('Update'),
|
||||
'contacts_batch_block' => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
|
||||
'contacts_batch_ignore' => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
|
||||
'contacts_batch_collapse' => DI::l10n()->t('Collapse') . '/' . DI::l10n()->t('Uncollapse'),
|
||||
],
|
||||
'$h_batch_actions' => DI::l10n()->t('Batch Actions'),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
|
|
|
@ -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 collapsed');
|
||||
} 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'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue