 
         UIView.animate(withDuration: Constants.NewMessageViewAnimationDuration, animations: {
             if show {
-                self.newMessageViewTopConstraint.update(offset: Constants.NewMessageViewTopOffset - self.newMessagesView.frame.size.height)
+                self.newMessageViewTopConstraint?.update(offset: Constants.NewMessageViewTopOffset - self.newMessagesView.frame.size.height)
             }
             else {
-                self.newMessageViewTopConstraint.update(offset: 0.0)
+                self.newMessageViewTopConstraint?.update(offset: 0.0)
             }
 
             self.view.layoutIfNeeded()


    fileprivate var tableViewTapGestureRecognizer: UITapGestureRecognizer!

    fileprivate var newMessageViewTopConstraint: Constraint!
    fileprivate var chatInputViewBottomConstraint: Constraint!

    fileprivate var newMessagesViewVisible = false

    /// Index path for cell with UIMenu presented.
    fileprivate var selectedMenuIndexPath: IndexPath?

    init(theme: Theme, chat: OCTChat, submanagerChats: OCTSubmanagerChats, submanagerObjects: OCTSubmanagerObjects, submanagerFiles: OCTSubmanagerFiles, delegate: ChatPrivateControllerDelegate) {
        self.theme = theme

    override func keyboardWillShowAnimated(keyboardFrame frame: CGRect) {
        super.keyboardWillShowAnimated(keyboardFrame: frame)

        guard let constraint = chatInputViewBottomConstraint else {
            return
        }

        constraint.update(offset: -frame.size.height)

        if disableNextInputViewAnimation {
            disableNextInputViewAnimation = false

            UIView.setAnimationsEnabled(false)
            view.layoutIfNeeded()
            UIView.setAnimationsEnabled(true)
        }
        else {
            view.layoutIfNeeded()
        }
    }

    override func keyboardWillHideAnimated(keyboardFrame frame: CGRect) {
        super.keyboardWillHideAnimated(keyboardFrame: frame)

        guard let constraint = chatInputViewBottomConstraint else {
            return
        }

        constraint.update(offset: 0.0)

        if disableNextInputViewAnimation {
            disableNextInputViewAnimation = false

            UIView.setAnimationsEnabled(false)
            view.layoutIfNeeded()
            UIView.setAnimationsEnabled(true)
        }
        else {
            view.layoutIfNeeded()
        }
    }

    override func viewDidLayoutSubviews() {
