provider->getForCustomer((int)$this->session->getCustomerId(), (int)$this->_storeManager->getStore()->getId(), (int)($this->getData('limit') ?: 50)); } public function getThreads(): array { return $this->conversations->getThreadsForCustomer((int)$this->session->getCustomerId(), (int)($this->getData('limit') ?: 100)); } public function getUnreadCount(): int { if ($this->unreadCount === null) { $customerId = (int)$this->session->getCustomerId(); $this->unreadCount = $customerId > 0 ? $this->conversations->getCustomerUnreadTotal($customerId) : 0; } return $this->unreadCount; } public function getSelectedThread(): ?array { if ((int)$this->getRequest()->getParam('new') === 1) { return null; } $threadId = (int)$this->getRequest()->getParam('thread_id'); if ($threadId) { return $this->conversations->getThreadForCustomer($threadId, (int)$this->session->getCustomerId()); } $orderId = (int)$this->getRequest()->getParam('order_id'); if ($orderId) { return $this->conversations->getOrderThreadForCustomer($orderId, (int)$this->session->getCustomerId()); } $threads = $this->getThreads(); return $threads ? $this->conversations->getThreadForCustomer((int)$threads[0]['thread_id'], (int)$this->session->getCustomerId()) : null; } public function getConversationMessages(?array $thread): array { return $thread ? $this->conversations->getMessages((int)$thread['thread_id']) : []; } public function getOrderId(): int { return (int)$this->getRequest()->getParam('order_id'); } public function getOrderIncrementId(): string { return (string)$this->getRequest()->getParam('order_increment_id'); } }