         DispatchQueue.main.async { [weak self] in
             guard let messages = self?.messages else { return }
 
-            if messages.count > 0 {
-                self?.activityIndicator.stopAnimating()
+            if messages.count == 0 {
+                self?.activityIndicator.startAnimating()
             }
 
             self?.scrollToBottom()

        CATransaction.begin()
        CATransaction.setDisableActions(true)
        let indexPaths = dataController.clear()
        collectionView?.performBatchUpdates({
            self.collectionView?.deleteItems(at: indexPaths)
        }, completion: { _ in
            CATransaction.commit()

            if self.subscription.isValid() {
                self.updateSubscriptionMessages()
            } else {
                self.subscription.fetchRoomIdentifier({ [weak self] response in
                    self?.subscription = response
                })
            }
        })

        if subscription.isJoined() {
            setTextInputbarHidden(false, animated: false)


            activityIndicatorContainer.addSubview(activityIndicator)
            self.activityIndicator = activityIndicator
        }
    }

    @IBOutlet weak var buttonFavorite: UIBarButtonItem!

    weak var chatTitleView: ChatTitleView?
    weak var chatPreviewModeView: ChatPreviewModeView?
    weak var chatHeaderViewOffline: ChatHeaderViewOffline?
