• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/integration/ui/entityselector/chatprovider.php
  • Класс: BitrixImIntegrationUIEntitySelectorChatProvider
  • Вызов: ChatProvider::fillRecentChats
private function fillRecentChats(array $recentChats, array $recentIds, array $preloadedChats): array
{
	if (count($recentIds) < 1)
	{
		return [];
	}

	$chatIds = array_values(array_diff($recentIds, array_column($preloadedChats, 'ID')));
	if (!empty($chatIds))
	{
		$chats = $this->getChatCollection(['chatIds' => $chatIds]);
		foreach ($chats as $chat)
		{
			$preloadedChats[] = $chat;
		}
	}

	foreach ($recentIds as $recentId)
	{
		$chat = $preloadedChats[$recentId] ?? null;
		if ($chat)
		{
			$recentChats[] = $chat;
		}
	}

	return $recentChats;
}