<commit_before>//
//  ChatCollectionViewFlowLayout.swift
//  Rocket.Chat
//
//  Created by <NAME> on 11/30/17.
//  Copyright © 2017 Rocket.Chat. All rights reserved.
//

import UIKit

class ChatCollectionViewFlowLayout: UICollectionViewFlowLayout {
    var heightOfInsertedItems: CGFloat = 0.0

    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint {
        let transform = CGAffineTransform(translationX: 0, y: heightOfInsertedItems)
        let offset = proposedContentOffset.applying(transform)
        heightOfInsertedItems = 0.0
        return offset
    }

    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
        let transform = CGAffineTransform(translationX: 0, y: heightOfInsertedItems)
        let offset = proposedContentOffset.applying(transform)
        heightOfInsertedItems = 0.0
        return offset
    }

    override func prepare(forCollectionViewUpdates updateItems: [UICollectionViewUpdateItem]) {
        super.prepare(forCollectionViewUpdates: updateItems)
        heightOfInsertedItems = updateItems.reduce(CGFloat(0.0)) { result, item in
            guard
                item.updateAction == .insert,
                let index = item.indexPathAfterUpdate,
                let attrs = layoutAttributesForItem(at: index)
            else {
                return result
            }

            return result + attrs.frame.height
        }
    }
}
<commit_msg>Prevent animations on adding new messages<commit_after>//
//  ChatCollectionViewFlowLayout.swift
//  Rocket.Chat
//
//  Created by <NAME> on 11/30/17.
//  Copyright © 2017 Rocket.Chat. All rights reserved.
//

import UIKit

class ChatCollectionViewFlowLayout: UICollectionViewFlowLayout {
    var heightOfInsertedItems: CGFloat = 0.0

    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint {
        let transform = CGAffineTransform(translationX: 0, y: heightOfInsertedItems)
        let offset = proposedContentOffset.applying(transform)
        heightOfInsertedItems = 0.0
        return offset
    }

    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
        let transform = CGAffineTransform(translationX: 0, y: heightOfInsertedItems)
        let offset = proposedContentOffset.applying(transform)
        heightOfInsertedItems = 0.0
        return offset
    }

    override func prepare(forCollectionViewUpdates updateItems: [UICollectionViewUpdateItem]) {
        super.prepare(forCollectionViewUpdates: updateItems)
        heightOfInsertedItems = updateItems.reduce(CGFloat(0.0)) { result, item in
            guard
                item.updateAction == .insert,
                let index = item.indexPathAfterUpdate,
                let attrs = layoutAttributesForItem(at: index)
            else {
                return result
            }

            return result + attrs.frame.height
        }

        CATransaction.begin()
        CATransaction.setDisableActions(true)
    }

    override func finalizeCollectionViewUpdates() {
        CATransaction.commit()
    }
}

{'fraction_non_alphanumeric': 0.07232224595666768, 'fraction_numerical': 0.012206286237412267, 'mean_word_length': 2.8519388954171565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3310406', 'n_tokens_mistral': 907, 'n_tokens_neox': 855, 'n_words': 197}