use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\DBA;
use Friendica\Database\Database;
-use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Circle;
use Friendica\Model\Item;
-use Friendica\Model\Post;
use Friendica\Model\Profile;
use Friendica\Model\Verb;
use Friendica\Module\Contact as ModuleContact;
/** @var string */
protected static $order;
+ /** @var App */
+ protected $app;
/** @var ICanCache */
protected $cache;
/** @var IManageConfigValues The config */
/** @var TimelineFactory */
protected $timeline;
- public function __construct(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(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($mode, $session, $database, $pConfig, $config, $cache, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+ $this->app = $app;
$this->timeline = $timeline;
$this->systemMessages = $systemMessages;
$this->conversation = $conversation;
}
}
- /**
- * Sets items as seen
- *
- * @param array $condition The array with the SQL condition
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
- private static function setItemsSeenByCondition(array $condition)
- {
- if (empty($condition)) {
- return;
- }
-
- $unseen = Post::exists($condition);
-
- if ($unseen) {
- /// @todo handle huge "unseen" updates in the background to avoid timeout errors
- Item::update(['unseen' => false], $condition);
- }
- }
-
/**
* Get the network tabs menu
*
self::$groupContactId = (int)($this->parameters['contact_id'] ?? 0);
if (!$this->selectedTab) {
- $this->selectedTab = self::getTimelineOrderBySession(DI::userSession(), $this->pConfig);
+ $this->selectedTab = self::getTimelineOrderBySession($this->session, $this->pConfig);
} elseif (!$this->timeline->isChannel($this->selectedTab) && !$this->timeline->isCommunity($this->selectedTab)) {
throw new HTTPException\BadRequestException($this->l10n->t('Network feed not available.'));
}
}
if (self::$dateFrom) {
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` <= ? ", DateTimeFormat::convert(self::$dateFrom, 'UTC', DI::app()->getTimeZone())]);
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` <= ? ", DateTimeFormat::convert(self::$dateFrom, 'UTC', $this->app->getTimeZone())]);
}
if (self::$dateTo) {
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` >= ? ", DateTimeFormat::convert(self::$dateTo, 'UTC', DI::app()->getTimeZone())]);
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` >= ? ", DateTimeFormat::convert(self::$dateTo, 'UTC', $this->app->getTimeZone())]);
}
if (self::$circleId) {
// at the top level network page just mark everything seen.
if (!self::$circleId && !self::$groupContactId && !self::$star && !self::$mention) {
$condition = ['unseen' => true, 'uid' => $this->session->getLocalUserId()];
- self::setItemsSeenByCondition($condition);
+ $this->setItemsSeenByCondition($condition);
} elseif (!empty($parents)) {
$condition = ['unseen' => true, 'uid' => $this->session->getLocalUserId(), 'parent-uri-id' => $parents];
- self::setItemsSeenByCondition($condition);
+ $this->setItemsSeenByCondition($condition);
}
return $items;
/** @var App\Mode $mode */
protected $mode;
- /** @var UserSession */
+ /** @var IHandleUserSessions */
protected $session;
/** @var Database */
protected $database;
$items = array_reverse($items);
}
- Item::update(['unseen' => false], ['unseen' => true, 'uid' => $uid, 'uri-id' => array_column($items, 'uri-id')]);
+ $condition = ['unseen' => true, 'uid' => $uid, 'parent-uri-id' => array_column($items, 'uri-id')];
+ $this->setItemsSeenByCondition($condition);
return $items;
}
$selected_items = $items;
}
+ $condition = ['unseen' => true, 'uid' => $this->session->getLocalUserId(), 'parent-uri-id' => array_column($selected_items, 'uri-id')];
+ $this->setItemsSeenByCondition($condition);
+
return $selected_items;
}
return $items;
}
+
+ /**
+ * Sets items as seen
+ *
+ * @param array $condition The array with the SQL condition
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ protected function setItemsSeenByCondition(array $condition)
+ {
+ if (empty($condition)) {
+ return;
+ }
+
+ $unseen = Post::exists($condition);
+
+ if ($unseen) {
+ /// @todo handle huge "unseen" updates in the background to avoid timeout errors
+ Item::update(['unseen' => false], $condition);
+ }
+ }
}