From 7510e854de8e9c08073b5ac7a0edf0d689026863 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 7 Mar 2021 20:15:25 +0000 Subject: [PATCH] Issue 8547: Improve page load speed --- src/Content/ContactSelector.php | 11 +++++++++-- src/Module/Contact.php | 4 ++-- src/Module/Group.php | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index dbf7e0a468..9ff7bb8653 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -117,7 +117,7 @@ class ContactSelector * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function networkToName($network, $profile = '', $protocol = '') + public static function networkToName($network, $profile = '', $protocol = '', $gsid = 0) { $nets = [ Protocol::DFRN => DI::l10n()->t('DFRN'), @@ -147,7 +147,14 @@ class ContactSelector $networkname = str_replace($search, $replace, $network); if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) { - $gserver = self::getServerForProfile($profile); + if (!empty($gsid) && !empty(self::$serverdata[$gsid])) { + $gserver = self::$serverdata[$gsid]; + } elseif (!empty($gsid)) { + $gserver = DBA::selectFirst('gserver', ['platform', 'network'], ['id' => $gsid]); + self::$serverdata[$gsid] = $gserver; + } else { + $gserver = self::getServerForProfile($profile); + } if (!empty($gserver['platform'])) { $platform = $gserver['platform']; diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 4334d31306..235b8488ab 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -536,7 +536,7 @@ class Contact extends BaseModule $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]); - $nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'])); + $nettype = DI::l10n()->t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'], $contact['gsid'])); // tabs $tab_str = self::getTabsHTML($contact, self::TAB_PROFILE); @@ -1113,7 +1113,7 @@ class Contact extends BaseModule 'account_type' => Model\Contact::getAccountType($contact), 'sparkle' => $sparkle, 'itemurl' => ($contact['addr'] ?? '') ?: $contact['url'], - 'network' => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']), + 'network' => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol'], $contact['gsid']), ]; } diff --git a/src/Module/Group.php b/src/Module/Group.php index 8da062a93e..cd2cc444e6 100644 --- a/src/Module/Group.php +++ b/src/Module/Group.php @@ -319,7 +319,8 @@ class Group extends BaseModule $contacts = Model\Contact\Group::listUngrouped(local_user()); } else { $contacts_stmt = DBA::select('contact', [], - ['uid' => local_user(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false], + ['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING], + 'uid' => local_user(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false], ['order' => ['name']] ); $contacts = DBA::toArray($contacts_stmt);