         guard let label = collectionView.backgroundView as? UILabel else { return }
 
         if data.cells.count == 0 {
+            if data.isSearchingMessages && (searchBar.text == nil || searchBar.text == "")
+                    || data.isLoadingSearchResults {
+                label.text = ""
+                return
+            }
+
             label.text = localized("chat.messages.list.empty")
         } else {
             label.text = ""


extension MessagesListViewController: UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return data.cells.count + (data.isShowingAllMessages ? 0 : 1)
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        guard indexPath.row < data.cells.count else {
            return collectionView.dequeueReusableCell(withReuseIdentifier: ChatLoaderCell.identifier, for: indexPath)
        }



extension MessagesListViewController: UISearchBarDelegate {
    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
        guard !searchText.isEmpty else {
            data.cellsPages = []
            collectionView.reloadData()
            updateIsEmptyMessage()
            return
        }

        self.data.isLoadingSearchResults = true
        self.collectionView.reloadData()
        self.updateIsEmptyMessage()

        searchTimer?.invalidate()
        searchTimer = Timer(timeInterval: 0.5, repeats: false, block: { _ in
            self.searchMessages(withText: searchText)
        })

        if let timer = searchTimer {
            RunLoop.main.add(timer, forMode: .commonModes)
        }
    }
}
