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: "DialogPage",
        mixins: [reactObserver],
        _onSubmit: function() {
            try {
                var node = this.refs.inputMessage.getDOMNode();
                var messageObj = node.value;
                node.value = "";
                this.props.pageModel.model.sendMessage(messageObj);
            } 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({ addPeople: true });
            //invite contact from current dialog to new group chat . test
            this._handleAddContact(null);
            return false;
        },
        _handleAddContact: function (contact) {
            var dialog = this.state.model;
            if(!dialog.hasSecureChannels()){
                //return false;
            }
            var profile = dialog.profile;
            var chat = profile.startGroupChat(dialog.contacts[0]);
            //dialog.contacts[0].sendTlgrInvite({invite:"invite"});
            this.props.router.createNavigateHandler("groupChat", chat)();
            return false;
        },
        _onConfigure: function () {
            var dialog = this.props.pageModel.model;
            // TODO this is kinda dumb
            this.props.router.navigate("contact", dialog.contacts[0]);
        },
        render: function () {
            var dialog = 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.form({ onSubmit: this._onSubmit }, React.DOM.input({ ref: "inputMessage" })),
                React.DOM.div({ className: "send-button" }, React.DOM.button({ onClick: this._onSubmit }, randomItem(words))));
            var configure = React.DOM.div({ className: "message-input" },
                React.DOM.button({ onClick: this._onConfigure }, "Configure secure channel"));

            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", dialog.profile)
                    }, "〈 Dialog: " + dialog.name),
                    React.DOM.a({
                        className: "header-button",
                        href: "",
                        onClick: this._onAddPeople
                    }, "Add People")),
                React.DOM.div({ className: "app-page-content has-header has-footer" },
                    MessagesView({ messages: dialog.messages })),
                   // ContactList({ contacts: dialog.profile.contacts, onClick: this._handleAddContact })),
                React.DOM.div({ className: "app-page-footer" },
                    React.DOM.div({ className: "tabs-header" },
                        React.DOM.div({ className: "tab-title" }, "Secure channel")),
                    React.DOM.div({ className: "tabs-content" },
                        dialog.hasSecureChannels() ? input : configure)));
        }
    });
})


@@ -1486,197 +1486,196 @@
     
-if(!dialog.hasSecureChannels())%7B%0D%0A                //return false;%0D%0A            %7D%0D%0A            var profile = dialog.profile;%0D%0A            var chat = profile.startGroupChat(dialog.contacts%5B0%5D
+var profile = dialog.profile;%0D%0A            var chat = profile.startGroupChat();%0D%0A            if(dialog.hasSecureChannels())%7B%0D%0A                var invitation = chat.tlgr.generateInvitation(
 );%0D%0A
@@ -1686,18 +1686,20 @@
         
-//
+    
 dialog.c
@@ -1736,19 +1736,37 @@
 ite:
-%22
+ 
 invit
-e%22%7D);
+ation%7D);%0D%0A            %7D
 %0D%0A  

add people tweaks