From: Michael Date: Fri, 6 Oct 2023 11:38:29 +0000 (+0000) Subject: Clean channel confusion X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3f6480c12704a1f616a350977930c3ab0e3836cb;p=friendica.git Clean channel confusion --- diff --git a/src/Content/Conversation/Factory/Timeline.php b/src/Content/Conversation/Factory/Timeline.php index eb40100819..804f6a3382 100644 --- a/src/Content/Conversation/Factory/Timeline.php +++ b/src/Content/Conversation/Factory/Timeline.php @@ -35,15 +35,15 @@ class Timeline extends \Friendica\BaseFactory implements ICanCreateFromTableRow /** @var IManageConfigValues The config */ protected $config; /** @var Channel */ - protected $channel; + protected $channelRepository; public function __construct(Channel $channel, L10n $l10n, LoggerInterface $logger, IManageConfigValues $config) { parent::__construct($logger); - $this->channel = $channel; - $this->l10n = $l10n; - $this->config = $config; + $this->channelRepository = $channel; + $this->l10n = $l10n; + $this->config = $config; } public function createFromTableRow(array $row): TimelineEntity diff --git a/src/Content/Conversation/Factory/UserDefinedChannel.php b/src/Content/Conversation/Factory/UserDefinedChannel.php index fe469a7b6f..cb3e86c1d7 100644 --- a/src/Content/Conversation/Factory/UserDefinedChannel.php +++ b/src/Content/Conversation/Factory/UserDefinedChannel.php @@ -42,7 +42,7 @@ final class UserDefinedChannel extends Timeline */ public function getForUser(int $uid): Timelines { - foreach ($this->channel->selectByUid($uid) as $channel) { + foreach ($this->channelRepository->selectByUid($uid) as $channel) { $tabs[] = $channel; } @@ -51,6 +51,6 @@ final class UserDefinedChannel extends Timeline public function isTimeline(string $selectedTab, int $uid): bool { - return is_numeric($selectedTab) && $uid && $this->channel->existsById($selectedTab, $uid); + return is_numeric($selectedTab) && $uid && $this->channelRepository->existsById($selectedTab, $uid); } } diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index 261a5a5d48..dab17c4e19 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -32,7 +32,6 @@ 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\Conversation\Factory\UserDefinedChannel; use Friendica\Content\Feature; use Friendica\Content\Nav; use Friendica\Content\Text\HTML; @@ -63,7 +62,7 @@ class Channel extends Timeline /** @var SystemMessages */ protected $systemMessages; /** @var ChannelFactory */ - protected $channelFactory; + protected $channel; /** @var UserDefinedChannelFactory */ protected $userDefinedChannel; /** @var CommunityFactory */ @@ -79,7 +78,7 @@ class Channel extends Timeline $this->conversation = $conversation; $this->page = $page; $this->systemMessages = $systemMessages; - $this->channelFactory = $channelFactory; + $this->channel = $channelFactory; $this->community = $community; $this->networkFactory = $network; $this->userDefinedChannel = $userDefinedChannel; @@ -105,7 +104,7 @@ class Channel extends Timeline } if (empty($request['mode']) || ($request['mode'] != 'raw')) { - $tabs = $this->getTabArray($this->channelFactory->getTimelines($this->session->getLocalUserId()), 'channel'); + $tabs = $this->getTabArray($this->channel->getTimelines($this->session->getLocalUserId()), 'channel'); $tabs = array_merge($tabs, $this->getTabArray($this->userDefinedChannel->getForUser($this->session->getLocalUserId()), 'channel')); $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'channel')); @@ -128,7 +127,7 @@ class Channel extends Timeline $o .= $this->conversation->statusEditor([], 0, true); } - if ($this->channelFactory->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { $items = $this->getChannelItems(); $order = 'created'; } else { @@ -174,7 +173,7 @@ class Channel extends Timeline $this->selectedTab = ChannelEntity::FORYOU; } - if (!$this->channelFactory->isTimeline($this->selectedTab) && !$this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) { + if (!$this->channel->isTimeline($this->selectedTab) && !$this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) { throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.')); } diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index f754b41260..40f7d1239e 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -101,7 +101,7 @@ class Network extends Timeline /** @var TimelineFactory */ protected $timeline; /** @var ChannelFactory */ - protected $channelFactory; + protected $channel; /** @var UserDefinedChannelFactory */ protected $userDefinedChannel; /** @var CommunityFactory */ @@ -118,7 +118,7 @@ class Network extends Timeline $this->systemMessages = $systemMessages; $this->conversation = $conversation; $this->page = $page; - $this->channelFactory = $channelFactory; + $this->channel = $channelFactory; $this->community = $community; $this->networkFactory = $network; $this->userDefinedChannel = $userDefinedChannel; @@ -139,7 +139,7 @@ class Network extends Timeline $o = ''; - if ($this->channelFactory->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { $items = $this->getChannelItems(); } elseif ($this->community->isTimeline($this->selectedTab)) { $items = $this->getCommunityItems(); @@ -286,7 +286,7 @@ class Network extends Timeline $network_timelines = $this->pConfig->get($this->session->getLocalUserId(), 'system', 'network_timelines', []); if (!empty($network_timelines)) { - $tabs = array_merge($tabs, $this->getTabArray($this->channelFactory->getTimelines($this->session->getLocalUserId()), 'network', 'channel')); + $tabs = array_merge($tabs, $this->getTabArray($this->channel->getTimelines($this->session->getLocalUserId()), 'network', 'channel')); $tabs = array_merge($tabs, $this->getTabArray($this->userDefinedChannel->getForUser($this->session->getLocalUserId()), 'network', 'channel')); $tabs = array_merge($tabs, $this->getTabArray($this->community->getTimelines(true), 'network', 'channel')); } @@ -321,11 +321,11 @@ class Network extends Timeline if (!$this->selectedTab) { $this->selectedTab = self::getTimelineOrderBySession($this->session, $this->pConfig); - } elseif (!$this->networkFactory->isTimeline($this->selectedTab) && !$this->channelFactory->isTimeline($this->selectedTab) && !$this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) && !$this->community->isTimeline($this->selectedTab)) { + } elseif (!$this->networkFactory->isTimeline($this->selectedTab) && !$this->channel->isTimeline($this->selectedTab) && !$this->userDefinedChannel->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->channelFactory->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) || $this->community->isTimeline($this->selectedTab))) { + if (($this->network || $this->circleId || $this->groupContactId) && ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId()) || $this->community->isTimeline($this->selectedTab))) { $this->selectedTab = NetworkEntity::RECEIVED; } @@ -350,7 +350,7 @@ class Network extends Timeline $this->mention = false; } elseif (in_array($this->selectedTab, [NetworkEntity::RECEIVED, NetworkEntity::STAR]) || $this->community->isTimeline($this->selectedTab)) { $this->order = 'received'; - } elseif (($this->selectedTab == NetworkEntity::CREATED) || $this->channelFactory->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + } elseif (($this->selectedTab == NetworkEntity::CREATED) || $this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { $this->order = 'created'; } else { $this->order = 'commented'; diff --git a/src/Module/Conversation/Timeline.php b/src/Module/Conversation/Timeline.php index 3f7f3ef759..8ddba16c71 100644 --- a/src/Module/Conversation/Timeline.php +++ b/src/Module/Conversation/Timeline.php @@ -81,19 +81,19 @@ class Timeline extends BaseModule /** @var ICanCache */ protected $cache; /** @var Channel */ - protected $channel; + protected $channelRepository; public function __construct(Channel $channel, 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($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); - $this->channel = $channel; - $this->mode = $mode; - $this->session = $session; - $this->database = $database; - $this->pConfig = $pConfig; - $this->config = $config; - $this->cache = $cache; + $this->channelRepository = $channel; + $this->mode = $mode; + $this->session = $session; + $this->database = $database; + $this->pConfig = $pConfig; + $this->config = $config; + $this->cache = $cache; } /** @@ -368,7 +368,7 @@ class Timeline extends BaseModule private function getUserChannelConditions(int $id, int $uid): array { - $channel = $this->channel->selectById($id, $uid); + $channel = $this->channelRepository->selectById($id, $uid); if (empty($channel)) { return []; } diff --git a/src/Module/Update/Channel.php b/src/Module/Update/Channel.php index 9382512da5..8435a7cc1b 100644 --- a/src/Module/Update/Channel.php +++ b/src/Module/Update/Channel.php @@ -38,7 +38,7 @@ class Channel extends ChannelModule $o = ''; if ($this->update || $this->force) { - if ($this->channelFactory->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { $items = $this->getChannelItems(); } else { $items = $this->getCommunityItems(); diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index 64f5ea5733..983680ac0b 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -41,7 +41,7 @@ class Network extends NetworkModule System::htmlUpdateExit($o); } - if ($this->channelFactory->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { $items = $this->getChannelItems(); } elseif ($this->community->isTimeline($this->selectedTab)) { $items = $this->getCommunityItems();