mirror of
https://github.com/friendica/friendica
synced 2025-04-24 13:50:10 +00:00
Timeline classes are split into multiple classes
This commit is contained in:
parent
5d6e02bef3
commit
6a86eeda10
19 changed files with 523 additions and 173 deletions
|
@ -25,9 +25,12 @@ use Friendica\App;
|
|||
use Friendica\App\Mode;
|
||||
use Friendica\Content\BoundariesPager;
|
||||
use Friendica\Content\Conversation;
|
||||
use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
|
||||
use Friendica\Content\Conversation\Entity\Network as NetworkEntity;
|
||||
use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
|
||||
use Friendica\Content\Conversation\Repository\Channel;
|
||||
use Friendica\Content\Conversation\Factory\Channel as ChannelFactory;
|
||||
use Friendica\Content\Conversation\Factory\Community as CommunityFactory;
|
||||
use Friendica\Content\Conversation\Factory\Network as NetworkFactory;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\GroupManager;
|
||||
use Friendica\Content\Nav;
|
||||
|
@ -96,8 +99,14 @@ class Network extends Timeline
|
|||
protected $database;
|
||||
/** @var TimelineFactory */
|
||||
protected $timeline;
|
||||
/** @var ChannelFactory */
|
||||
protected $channel;
|
||||
/** @var CommunityFactory */
|
||||
protected $community;
|
||||
/** @var NetworkFactory */
|
||||
protected $networkFactory;
|
||||
|
||||
public function __construct(Channel $channel, App $app, TimelineFactory $timeline, SystemMessages $systemMessages, Mode $mode, Conversation $conversation, App\Page $page, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
public function __construct(NetworkFactory $network, CommunityFactory $community, ChannelFactory $channelFactory, Channel $channel, App $app, TimelineFactory $timeline, SystemMessages $systemMessages, Mode $mode, Conversation $conversation, App\Page $page, IHandleUserSessions $session, Database $database, IManagePersonalConfigValues $pConfig, IManageConfigValues $config, ICanCache $cache, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($channel, $mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
|
@ -106,6 +115,9 @@ class Network extends Timeline
|
|||
$this->systemMessages = $systemMessages;
|
||||
$this->conversation = $conversation;
|
||||
$this->page = $page;
|
||||
$this->channel = $channelFactory;
|
||||
$this->community = $community;
|
||||
$this->networkFactory = $network;
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
|
@ -123,9 +135,9 @@ class Network extends Timeline
|
|||
|
||||
$o = '';
|
||||
|
||||
if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
|
||||
if ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
|
||||
$items = $this->getChannelItems();
|
||||
} elseif ($this->timeline->isCommunity($this->selectedTab)) {
|
||||
} elseif ($this->community->isTimeline($this->selectedTab)) {
|
||||
$items = $this->getCommunityItems();
|
||||
} else {
|
||||
$items = $this->getItems();
|
||||
|
@ -266,12 +278,12 @@ class Network extends Timeline
|
|||
*/
|
||||
private function getTabsHTML()
|
||||
{
|
||||
$tabs = $this->getTabArray($this->timeline->getNetworkFeeds($this->args->getCommand()), 'network');
|
||||
$tabs = $this->getTabArray($this->networkFactory->getTimelines($this->args->getCommand()), 'network');
|
||||
|
||||
$network_timelines = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'network_timelines', []);
|
||||
if (!empty($network_timelines)) {
|
||||
$tabs = array_merge($tabs, $this->getTabArray($this->timeline->getChannelsForUser($this->session->getLocalUserId()), 'network', 'channel'));
|
||||
$tabs = array_merge($tabs, $this->getTabArray($this->timeline->getCommunities(true), 'network', 'channel'));
|
||||
$tabs = array_merge($tabs, $this->getTabArray($this->channel->getForUser($this->session->getLocalUserId()), 'network', 'channel'));
|
||||
$tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'network', 'channel'));
|
||||
}
|
||||
|
||||
$arr = ['tabs' => $tabs];
|
||||
|
@ -304,26 +316,26 @@ class Network extends Timeline
|
|||
|
||||
if (!$this->selectedTab) {
|
||||
$this->selectedTab = self::getTimelineOrderBySession($this->session, $this->pConfig);
|
||||
} elseif (!$this->timeline->isNetwork($this->selectedTab) && !$this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId()) && !$this->timeline->isCommunity($this->selectedTab)) {
|
||||
} elseif (!$this->networkFactory->isTimeline($this->selectedTab) && !$this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) {
|
||||
throw new HTTPException\BadRequestException($this->l10n->t('Network feed not available.'));
|
||||
}
|
||||
|
||||
if (($this->network || $this->circleId || $this->groupContactId) && ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId()) || $this->timeline->isCommunity($this->selectedTab))) {
|
||||
$this->selectedTab = TimelineEntity::RECEIVED;
|
||||
if (($this->network || $this->circleId || $this->groupContactId) && ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) || $this->community->isTimeline($this->selectedTab))) {
|
||||
$this->selectedTab = NetworkEntity::RECEIVED;
|
||||
}
|
||||
|
||||
if (!empty($request['star'])) {
|
||||
$this->selectedTab = TimelineEntity::STAR;
|
||||
$this->selectedTab = NetworkEntity::STAR;
|
||||
$this->star = true;
|
||||
} else {
|
||||
$this->star = $this->selectedTab == TimelineEntity::STAR;
|
||||
$this->star = $this->selectedTab == NetworkEntity::STAR;
|
||||
}
|
||||
|
||||
if (!empty($request['mention'])) {
|
||||
$this->selectedTab = TimelineEntity::MENTION;
|
||||
$this->selectedTab = NetworkEntity::MENTION;
|
||||
$this->mention = true;
|
||||
} else {
|
||||
$this->mention = $this->selectedTab == TimelineEntity::MENTION;
|
||||
$this->mention = $this->selectedTab == NetworkEntity::MENTION;
|
||||
}
|
||||
|
||||
if (!empty($request['order'])) {
|
||||
|
@ -331,9 +343,9 @@ class Network extends Timeline
|
|||
$this->order = $request['order'];
|
||||
$this->star = false;
|
||||
$this->mention = false;
|
||||
} elseif (in_array($this->selectedTab, [TimelineEntity::RECEIVED, TimelineEntity::STAR]) || $this->timeline->isCommunity($this->selectedTab)) {
|
||||
} elseif (in_array($this->selectedTab, [NetworkEntity::RECEIVED, NetworkEntity::STAR]) || $this->community->isTimeline($this->selectedTab)) {
|
||||
$this->order = 'received';
|
||||
} elseif (($this->selectedTab == TimelineEntity::CREATED) || $this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
|
||||
} elseif (($this->selectedTab == NetworkEntity::CREATED) || $this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
|
||||
$this->order = 'created';
|
||||
} else {
|
||||
$this->order = 'commented';
|
||||
|
@ -343,16 +355,16 @@ class Network extends Timeline
|
|||
|
||||
// Upon updates in the background and order by last comment we order by received date,
|
||||
// since otherwise the feed will optically jump, when some already visible thread has been updated.
|
||||
if ($this->update && ($this->selectedTab == TimelineEntity::COMMENTED)) {
|
||||
if ($this->update && ($this->selectedTab == NetworkEntity::COMMENTED)) {
|
||||
$this->order = 'received';
|
||||
$request['last_received'] = $request['last_commented'] ?? null;
|
||||
$request['first_received'] = $request['first_commented'] ?? null;
|
||||
}
|
||||
|
||||
// Prohibit combined usage of "star" and "mention"
|
||||
if ($this->selectedTab == TimelineEntity::STAR) {
|
||||
if ($this->selectedTab == NetworkEntity::STAR) {
|
||||
$this->mention = false;
|
||||
} elseif ($this->selectedTab == TimelineEntity::MENTION) {
|
||||
} elseif ($this->selectedTab == NetworkEntity::MENTION) {
|
||||
$this->star = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue