     ///   - indexPath: The `IndexPath` of the cell.
     open func sizeForItem(at indexPath: IndexPath) -> CGSize {
         let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView)
-        let context = cellLayoutContext(for: message, at: indexPath)
-        guard let itemHeight = context.itemHeight else {
-            fatalError("Unexpectedly received a nil itemHeight")
-        }
+        let itemHeight = cellContentHeight(for: message, at: indexPath)
         return CGSize(width: itemWidth, height: itemHeight)
     }
 }

        switch message.data {
        case .text(let text):
            let messageInsets = messageLabelInsets(for: message, at: indexPath)
            messageContainerSize = labelSize(for: text, considering: maxWidth, and: messageLabelFont)
            messageContainerSize.width += messageInsets.horizontal
            messageContainerSize.height += messageInsets.vertical
        case .attributedText(let text):

            messageContainerSize.height += messageInsets.vertical
        case .emoji(let text):
            let messageInsets = messageLabelInsets(for: message, at: indexPath)
            let attributedText = NSAttributedString(string: text, attributes: [.font: emojiLabelFont])
            messageContainerSize = labelSize(for: attributedText, considering: maxWidth)
            messageContainerSize.width += messageInsets.horizontal
            messageContainerSize.height += messageInsets.vertical
        case .photo, .video:
