contact discovery works now

This commit is contained in:
Gene S
2016-08-29 18:04:52 -07:00
parent 2e4b165b42
commit e9de7d89fd
+25 -9
View File
@@ -24,7 +24,7 @@
<div id="mountPoint"></div> <div id="mountPoint"></div>
<script type="text/babel"> <script type="text/babel">
// Name of this application, used in the User-Agent // Name of this application, used in the User-Agent
var APP_NAME = "TinodeReact/0.7"; var APP_NAME = "TinodeReact/0.8";
// Host name and port to connect to // Host name and port to connect to
// var HOST = "api.tinode.co"; // var HOST = "api.tinode.co";
@@ -278,10 +278,12 @@
} else { } else {
this.setState({errorCleared: false}); this.setState({errorCleared: false});
var vcard = null; var vcard = null;
if (this.state.name.trim() || this.state.imageDataUrl) {
vcard = { if ((this.state.fn && this.state.fn.trim()) || this.state.imageDataUrl) {
fn: this.state.name.trim(), vcard = {};
}; if (this.state.fn) {
vcard.fn = this.state.fn.trim();
}
if (this.state.imageDataUrl) { if (this.state.imageDataUrl) {
var dataStart = this.state.imageDataUrl.indexOf(","); var dataStart = this.state.imageDataUrl.indexOf(",");
vcard.photo = { vcard.photo = {
@@ -300,7 +302,7 @@
} }
return ( return (
<div> <div>
<form className="panel-form" onSubmit={this.handleSubmit} onCancel={this.props.onCancel}> <form className="panel-form" onSubmit={this.handleSubmit}>
<div className="panel-form-one"> <div className="panel-form-one">
<div className="panel-form-two"> <div className="panel-form-two">
<input type="text" placeholder="Login" <input type="text" placeholder="Login"
@@ -565,7 +567,7 @@
this.props.state === 'new-topic' ? this.props.state === 'new-topic' ?
<NewTopicView <NewTopicView
data={this.props.subscriptions} data={this.props.subscriptions}
onContactSelected={this.props.onContactSelected} onSearchContacts={this.props.onSearchContacts}
onCreateTopic={this.props.onCreateTopic} /> : onCreateTopic={this.props.onCreateTopic} /> :
null} null}
@@ -814,7 +816,7 @@
{this.state.tabSelected === "grp" ? {this.state.tabSelected === "grp" ?
<NewTopicView.Group onSubmit={this.handleGroupSubmit} /> : <NewTopicView.Group onSubmit={this.handleGroupSubmit} /> :
<div className="flex-column"> <div className="flex-column">
<NewTopicView.SearchContacts type="p2p" /> <NewTopicView.SearchContacts type="p2p" onSearchContacts={this.props.onSearchContacts} />
<NewTopicView.ContactsList onContactSelected={this.handleContactSelected} type="p2p" /> <NewTopicView.ContactsList onContactSelected={this.handleContactSelected} type="p2p" />
</div>} </div>}
</div> </div>
@@ -837,7 +839,9 @@
}, },
handleSubmit: function(e) { handleSubmit: function(e) {
e.preventDefault(); e.preventDefault();
if (this.state.fn && this.state.fn.trim()) {
this.props.onSubmit(this.state.fn.trim(), this.state.imageDataUrl); this.props.onSubmit(this.state.fn.trim(), this.state.imageDataUrl);
}
}, },
render: function() { render: function() {
var submitClasses = "blue"; var submitClasses = "blue";
@@ -874,7 +878,9 @@
e.preventDefault(); e.preventDefault();
// Split query string by either space or comma, filter out empty strings. // Split query string by either space or comma, filter out empty strings.
var query = this.state.search.split(/[,\s]/).filter(Boolean); var query = this.state.search.split(/[,\s]/).filter(Boolean);
console.log("will search for ", query); if (query.length > 0) {
this.props.onSearchContacts(query);
}
}, },
render: function() { render: function() {
return ( return (
@@ -1503,6 +1509,15 @@
}); });
} }
}, },
/** Called when the user enters a contact into the contact search field in the NewAccount panel
@param query {Array} is an array of contacts to search for
*/
handleSearchContacts: function(query) {
var find = Tinode.getFndTopic();
find.setMeta({desc: {private: query}}).then(function() {
find.getMeta({sub: {}});
});
},
handleDialogCancel: function() { handleDialogCancel: function() {
this.setState({dialogSelected: null}); this.setState({dialogSelected: null});
}, },
@@ -1566,6 +1581,7 @@
onLoginRequest={this.handleLoginRequest} onLoginRequest={this.handleLoginRequest}
onCreateAccount={this.handleNewAccountRequest} onCreateAccount={this.handleNewAccountRequest}
onTopicSelected={this.handleTopicSelected} onTopicSelected={this.handleTopicSelected}
onSearchContacts={this.handleSearchContacts}
onCreateTopic={this.handleNewTopicRequest} onCreateTopic={this.handleNewTopicRequest}
onNewTopic={this.handleNewTopic} onNewTopic={this.handleNewTopic}
onCancel={this.handleSidepanelCancel} onCancel={this.handleSidepanelCancel}