Timeline classes are split into multiple classes

This commit is contained in:
Michael 2023-10-05 05:36:12 +00:00
parent 5d6e02bef3
commit 6a86eeda10
19 changed files with 523 additions and 173 deletions

View file

@ -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\Channel as ChannelEntity;
use Friendica\Content\Conversation\Factory\Timeline as TimelineFactory;
use Friendica\Content\Conversation\Repository\Channel as ChannelRepository;
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\Nav;
use Friendica\Content\Text\HTML;
@ -57,8 +60,14 @@ class Channel extends Timeline
protected $page;
/** @var SystemMessages */
protected $systemMessages;
/** @var ChannelFactory */
protected $channel;
/** @var CommunityFactory */
protected $community;
/** @var NetworkFactory */
protected $networkFactory;
public function __construct(ChannelRepository $channel, TimelineFactory $timeline, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, 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, ChannelRepository $channel, TimelineFactory $timeline, Conversation $conversation, App\Page $page, SystemMessages $systemMessages, Mode $mode, 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);
@ -66,6 +75,9 @@ class Channel extends Timeline
$this->conversation = $conversation;
$this->page = $page;
$this->systemMessages = $systemMessages;
//$this->channel = $channelFactory;
$this->community = $community;
$this->networkFactory = $network;
}
protected function content(array $request = []): string
@ -88,8 +100,8 @@ class Channel extends Timeline
}
if (empty($request['mode']) || ($request['mode'] != 'raw')) {
$tabs = $this->getTabArray($this->timeline->getChannelsForUser($this->session->getLocalUserId()), 'channel');
$tabs = array_merge($tabs, $this->getTabArray($this->timeline->getCommunities(true), 'channel'));
$tabs = $this->getTabArray($this->channel->getForUser($this->session->getLocalUserId()), 'channel');
$tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel'));
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
@ -98,7 +110,7 @@ class Channel extends Timeline
$this->page['aside'] .= Widget::accountTypes('channel/' . $this->selectedTab, $this->accountTypeString);
if (!in_array($this->selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
if (!in_array($this->selectedTab, [ChannelEntity::FOLLOWERS, ChannelEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
$this->page['aside'] .= $this->getNoSharerWidget('channel');
}
@ -110,7 +122,7 @@ class Channel extends Timeline
$o .= $this->conversation->statusEditor([], 0, true);
}
if ($this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId())) {
if ($this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
$items = $this->getChannelItems();
$order = 'created';
} else {
@ -153,10 +165,10 @@ class Channel extends Timeline
parent::parseRequest($request);
if (!$this->selectedTab) {
$this->selectedTab = TimelineEntity::FORYOU;
$this->selectedTab = ChannelEntity::FORYOU;
}
if (!$this->timeline->isChannel($this->selectedTab, $this->session->getLocalUserId()) && !$this->timeline->isCommunity($this->selectedTab)) {
if (!$this->channel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) {
throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
}