<commit_before>define(function(require, exports, module) {
    "use strict";
    var React = require("react");
    var reactObserver = require("mixins/reactObserver");
    var MessagesView = require("./MessagesView");
    var ContactList = require("ui/contacts/ContactList");
    module.exports = React.createClass({
        displayName: "GroupChatPage",
        mixins: [reactObserver],
        getInitialState: function () {
            return {
                messageText: "",
                showMembers: false,
                addContact: false
            };
        },
        _onSubmit: function() {
            try {
                this.props.pageModel.model.sendMessage(this.state.messageText);
                this.setState({messageText:""});
            } catch (ex) {
                console.error(ex);
            }
            return false;
        },
        componentDidMount: function() {
            var dialog = this.props.pageModel.model;
            dialog.markAsRead();
            dialog.on("changed", dialog.markAsRead, dialog);
        },
        componentWillUnmount: function() {
            var dialog = this.props.pageModel.model;
            dialog.off("changed", dialog.markAsRead, dialog);
        },
        _onAddPeople: function() {
            //this.setState({ addContact: !this.state.addContact });
            this.state.showMembers = false;
            this.state.pageModel.set("addContact", !this.state.pageModel.addContact);
            return false;
        },
        _handleMembers: function() {
            this.setState({ showMembers: !this.state.showMembers });
            return false;
        },
        _handleAddContact: function(contact) {
            var groupChat = this.state.model;
            var profile = groupChat.profile;
            if(contact.tlConnection.canSendMessages()){
                var invitation = groupChat.tlgr.generateInvitation();
                contact.sendTlgrInvite({invite: invitation});
            }
            this.state.pageModel.set("addContact", false);
            return false;
        },

        _handleLeaveChat: function (e) {
            e.preventDefault();
            this.state.model.profile.leaveGroupChat(this.state.model);
            this.props.router.createNavigateHandler("dialogs", this.state.model.profile)();
            return false;
        },

        renderMembers: function () {
            return this.state.model.tlgr.getUsers().map(function (aid) {
                return React.DOM.div({
                    className: "generic-block contact clearfix"
                },
                    React.DOM.div({ className: "contact-image" }, ""),
                    React.DOM.div({ className: "contact-title" }, "user" + aid)
                    );
            }, this);
        },

        render: function () {
            var groupChat = this.state.model;
            //            var pageModel = this.state.pageModel;
            var router = this.props.router;

            var words = ["POP!", "POOF!", "BANG!", "ZAP!", "WHOOSH!", "POW!", "BONG!", "KA-POW!", "SNAP!", "CRACK!", "SIZZLE!", "BAM!"]
            function randomItem(list) {
                return list[Math.floor(Math.random() * list.length)];
            }

            var input = React.DOM.div({ className: "message-input" },
                    React.DOM.input({
                        type: "text",
                        value: this.state.messageText,
                        onChange: function (e) { this.setState({ messageText: e.target.value });}.bind(this)
                    }),
                React.DOM.div({ className: "send-button" }, React.DOM.button({ onClick: this._onSubmit }, randomItem(words))));
            var content;
            if (this.state.pageModel.addContact) {
                content = ContactList({ contacts: groupChat.profile.contacts, onClick: this._handleAddContact });
            } else if (this.state.showMembers) {
                content = this.renderMembers();
            } else {
                content = MessagesView({ messages: groupChat.messages });
            }

            return React.DOM.div({ className: "dialog-page app-page" },
                React.DOM.div({ className: "app-page-header" },
                    React.DOM.a({
                        className: "title",
                        href: "",
                        onClick: router.createNavigateHandler("dialogs", groupChat.profile)
                    }, "〈 Group Chat: " + groupChat.name),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._onAddPeople
                    }, "Add People"),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._handleLeaveChat
                    }, "Leave"),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._handleMembers
                    }, "Members")),
                React.DOM.div({ className: "app-page-content has-header has-footer" },<commit_msg>more buttons for group chat page<commit_after>define(function(require, exports, module) {
    "use strict";
    var React = require("react");
    var reactObserver = require("mixins/reactObserver");
    var MessagesView = require("./MessagesView");
    var ContactList = require("ui/contacts/ContactList");
    module.exports = React.createClass({
        displayName: "GroupChatPage",
        mixins: [reactObserver],
        getInitialState: function () {
            return {
                messageText: "",
                showMembers: false,
                addContact: false
            };
        },
        _onSubmit: function() {
            try {
                this.props.pageModel.model.sendMessage(this.state.messageText);
                this.setState({messageText:""});
            } catch (ex) {
                console.error(ex);
            }
            return false;
        },
        componentDidMount: function() {
            var dialog = this.props.pageModel.model;
            dialog.markAsRead();
            dialog.on("changed", dialog.markAsRead, dialog);
        },
        componentWillUnmount: function() {
            var dialog = this.props.pageModel.model;
            dialog.off("changed", dialog.markAsRead, dialog);
        },
        _onAddPeople: function() {
            //this.setState({ addContact: !this.state.addContact });
            this.state.showMembers = false;
            this.state.pageModel.set("addContact", !this.state.pageModel.addContact);
            return false;
        },
        _handleMembers: function() {
            this.setState({ showMembers: !this.state.showMembers });
            return false;
        },
        _handleAddContact: function(contact) {
            var groupChat = this.state.model;
            var profile = groupChat.profile;
            if(contact.tlConnection.canSendMessages()){
                var invitation = groupChat.tlgr.generateInvitation();
                contact.sendTlgrInvite({invite: invitation});
            }
            this.state.pageModel.set("addContact", false);
            return false;
        },

        _handleLeaveChat: function (e) {
            e.preventDefault();
            this.state.model.profile.leaveGroupChat(this.state.model);
            this.props.router.createNavigateHandler("dialogs", this.state.model.profile)();
            return false;
        },

        _handleRekey: function (e) {
            e.preventDefault();
            this.state.model.tlgr.initiateRekey();
        },

        renderMembers: function () {
            return this.state.model.tlgr.getUsers().map(function (aid) {
                return React.DOM.div({
                    className: "generic-block contact clearfix"
                },
                    React.DOM.div({ className: "contact-image" }, ""),
                    React.DOM.div({ className: "contact-title" }, "user" + aid)
                    );
            }, this);
        },

        render: function () {
            var groupChat = this.state.model;
            //            var pageModel = this.state.pageModel;
            var router = this.props.router;

            var words = ["POP!", "POOF!", "BANG!", "ZAP!", "WHOOSH!", "POW!", "BONG!", "KA-POW!", "SNAP!", "CRACK!", "SIZZLE!", "BAM!"]
            function randomItem(list) {
                return list[Math.floor(Math.random() * list.length)];
            }

            var input = React.DOM.div({ className: "message-input" },
                    React.DOM.input({
                        type: "text",
                        value: this.state.messageText,
                        onChange: function (e) { this.setState({ messageText: e.target.value });}.bind(this)
                    }),
                React.DOM.div({ className: "send-button" }, React.DOM.button({ onClick: this._onSubmit }, randomItem(words))));
            var content;
            if (this.state.pageModel.addContact) {
                content = ContactList({ contacts: groupChat.profile.contacts, onClick: this._handleAddContact });
            } else if (this.state.showMembers) {
                content = this.renderMembers();
            } else {
                content = MessagesView({ messages: groupChat.messages });
            }

            return React.DOM.div({ className: "dialog-page app-page" },
                React.DOM.div({ className: "app-page-header" },
                    React.DOM.a({
                        className: "title",
                        href: "",
                        onClick: router.createNavigateHandler("dialogs", groupChat.profile)
                    }, "〈 Group Chat: " + groupChat.name),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._onAddPeople
                    }, "Add "),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._handleLeaveChat
                    }, "Leave "),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._handleMembers
                    }, "M "),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._handleRekey
                    }, "RK")),
                React.DOM.div({ className: "app-page-content has-header has-footer" },
{'fraction_non_alphanumeric': 0.12611111111111112, 'fraction_numerical': 0.0, 'mean_word_length': 1.4547727272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2737570', 'n_tokens_mistral': 2745, 'n_tokens_neox': 2668, 'n_words': 502}