- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/integration/ui/entityselector/chatprovider.php
- Класс: BitrixImIntegrationUIEntitySelectorChatProvider
- Вызов: ChatProvider::fillDialog
public function fillDialog(Dialog $dialog): void
{
if (!$this->shouldFillDialog())
{
return;
}
if (!$this->getOption('fillDialogWithDefaultValues', true))
{
$recentChats = [];
$recentItems = $dialog->getRecentItems()->getEntityItems(static::getEntityId());
$recentIds = array_map('intval', array_keys($recentItems));
$recentChats = $this->fillRecentChats($recentChats, $recentIds, []);
$dialog->addRecentItems($this->makeChatItems($recentChats));
return;
}
// Preload chats ('doSearch' method has to have the same filter).
$preloadedChats = $this->getPreloadedChatsCollection();
$recentChats = [];
// Recent Items
$recentItems = $dialog->getRecentItems()->getEntityItems(static::getEntityId());
$recentIds = array_map('intval', array_keys($recentItems));
$recentChats = $this->fillRecentChats($recentChats, $recentIds, $preloadedChats);
// Global Recent Items
if (count($recentChats) < self::MAX_CHATS_IN_RECENT_TAB)
{
$recentGlobalItems = $dialog->getGlobalRecentItems()->getEntityItems(static::getEntityId());
$recentGlobalIds = [];
if (!empty($recentGlobalItems))
{
$recentGlobalIds = array_map('intval', array_keys($recentGlobalItems));
$recentChatsIdList = array_column($recentChats, 'ID');
$recentGlobalIds = array_values(array_diff($recentGlobalIds, $recentChatsIdList));
$recentGlobalIds = array_slice(
$recentGlobalIds,
0,
self::MAX_CHATS_IN_RECENT_TAB - count($recentChats)
);
}
$recentChats = $this->fillRecentChats($recentChats, $recentGlobalIds, $preloadedChats);
}
// The rest of preloaded chats
foreach ($preloadedChats as $preloadedChat)
{
$recentChats[] = $preloadedChat;
}
$dialog->addRecentItems($this->makeChatItems($recentChats));
}