<commit_before>//
//  MessageCell.swift
//  OraChat
//
//  Created by <NAME> on 8/23/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import SnapKit

class MessageCell: UITableViewCell {

    static let messageWidth: CGFloat = 226.0
    static let verticalSpacing: CGFloat = 10.0
    static let fontSize: CGFloat = 15.0

    static let currentUserId: Int = {return fetchTokenAndIdFromKeychain().id! ?? -1}()

    private var messageLabel = BubbleLabel()

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.addSubview(messageLabel)
        messageLabel.snp_makeConstraints{ make in
            make.top.equalTo(self).offset(MessageCell.verticalSpacing)
            make.bottom.equalTo(self).offset(-MessageCell.verticalSpacing)
            make.left.equalTo(self).offset(0)
            make.width.equalTo(MessageCell.messageWidth)
        }
        messageLabel.font = UIFont.systemFontOfSize(MessageCell.fontSize)
        messageLabel.backgroundColor = UIColor.orangeColor()
        messageLabel.numberOfLines = 0
    }

    func inject(message message: Message) {
        messageLabel.text = message.text
        messageLabel.side = (message.userID == MessageCell.currentUserId) ? .Right : .Left
    }
}<commit_msg>pin message to appropriate side<commit_after>//
//  MessageCell.swift
//  OraChat
//
//  Created by <NAME> on 8/23/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import SnapKit

class MessageCell: UITableViewCell {

    static let messageWidth: CGFloat = 226.0
    static let verticalSpacing: CGFloat = 10.0
    static let fontSize: CGFloat = 15.0

    static let currentUserId: Int = {return fetchTokenAndIdFromKeychain().id! ?? -1}()

    private let containerView = UIView()
    private let messageLabel = BubbleLabel()
    private var leftConstraint: Constraint?
    private var rightConstraint: Constraint?

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.addSubview(containerView)
        containerView.snp_makeConstraints{ make in
            make.top.equalTo(self).offset(MessageCell.verticalSpacing)
            make.bottom.equalTo(self).offset(-MessageCell.verticalSpacing)
            leftConstraint = make.left.equalTo(self).offset(0).constraint
            rightConstraint = make.right.equalTo(self).offset(0).constraint
            make.width.equalTo(MessageCell.messageWidth)
        }
        rightConstraint?.uninstall()

        self.addSubview(messageLabel)
        messageLabel.snp_makeConstraints{ make in
            make.top.equalTo(containerView)
            make.bottom.equalTo(containerView)
            make.left.equalTo(containerView)
            make.right.equalTo(containerView)
        }
        messageLabel.font = UIFont.systemFontOfSize(MessageCell.fontSize)
        messageLabel.backgroundColor = UIColor.orangeColor()
        messageLabel.numberOfLines = 0
    }

    func inject(message message: Message) {
        messageLabel.text = message.text
        if message.userID == MessageCell.currentUserId {
            messageLabel.side = .Right
            leftConstraint?.uninstall()
            rightConstraint?.install()
        } else {
            messageLabel.side = .Left
            leftConstraint?.install()
            rightConstraint?.uninstall()
        }
    }
}
{'fraction_non_alphanumeric': 0.09880239520958084, 'fraction_numerical': 0.01347305389221557, 'mean_word_length': 2.6673984632272227, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3198156', 'n_tokens_mistral': 985, 'n_tokens_neox': 938, 'n_words': 189}