- if (!empty($request['item'])) {
- $item = Post::selectFirst(['parent'], ['id' => $request['item']]);
- $parent = $item['parent'] ?? 0;
- } else {
- $parent = 0;
- }
-
- $conditionFields = [];
- if (!empty($parent)) {
- // Load only a single thread
- $conditionFields['parent'] = $parent;
- } elseif (self::$order === 'received') {
- // Only load new toplevel posts
- $conditionFields['unseen'] = true;
- $conditionFields['gravity'] = Item::GRAVITY_PARENT;
- } else {
- // Load all unseen items
- $conditionFields['unseen'] = true;
- }
-
- $params = ['limit' => $this->itemsPerPage];
- $table = 'network-thread-view';
-
- $items = $this->getItems($table, $params, $conditionFields);