27 $messageId = $this->message->getMessageId() ?? 0;
28 $chat = $this->message->getChat();
30 $startId = $chat->getStartId();
36 $idsBefore = MessageTable::query()
38 ->where(
'ID',
'<', $messageId)
39 ->where(
'ID',
'>=', $startId)
40 ->where(
'CHAT_ID', $chat->getChatId())
41 ->setOrder([
'DATE_CREATE' =>
'DESC',
'ID' =>
'DESC'])
46 $idsAfter = MessageTable::query()
48 ->where(
'ID',
'>', $messageId)
49 ->where(
'CHAT_ID', $chat->getChatId())
50 ->setOrder([
'DATE_CREATE' =>
'ASC',
'ID' =>
'ASC'])
56 $targetMessage = $messageId < $startId ? [] : [$messageId];
58 $ids = array_merge($idsBefore, $targetMessage, $idsAfter);
70 $ormCollection = MessageTable::query()->whereIn(
'ID', $ids)->setSelect($select)->fetchCollection();
86 $rest[
'hasPrevPage'] = $this->getCountHigherMessages($messages, $this->message->getId() ?? 0) >= $range;
87 $lastSelectedId = $this->getLastSelectedId($messages);
88 $lastMessageIdInChat = $this->message->getChat()->getLastMessageId();
89 $rest[
'hasNextPage'] = $lastSelectedId > 0 && $lastMessageIdInChat > 0 && $lastSelectedId < $lastMessageIdInChat;