new search works now

This commit is contained in:
or-else
2018-05-09 19:00:15 -07:00
parent d5c7464570
commit 189fc0e3f2
+9 -11
View File
@@ -2373,8 +2373,7 @@
}, },
handleSearch: function(e) { handleSearch: function(e) {
e.preventDefault(); e.preventDefault();
// Split query string by either space or comma, filter out empty strings. var query = this.state.search.trim();
var query = this.state.search.split(/[,\s]/).filter(Boolean);
if (query.length > 0) { if (query.length > 0) {
this.props.onSearchContacts(query); this.props.onSearchContacts(query);
} }
@@ -3258,13 +3257,13 @@
if (!topic.isSubscribed() && tryToResubscribe) { if (!topic.isSubscribed() && tryToResubscribe) {
var instance = this; var instance = this;
topic.subscribe(topic.startMetaQuery() var getQuery = topic.startMetaQuery()
.withLaterDesc() .withLaterDesc()
.withLaterSub() .withLaterSub()
.withLaterData(MESSAGES_PAGE) .withLaterData(MESSAGES_PAGE)
.withLaterDel() .withLaterDel();
.withTags() getQuery = topic.getType() == 'grp' ? getQuery.withTags() : getQuery;
.build()).catch(function(err){ topic.subscribe(getQuery.build()).catch(function(err){
instance.props.onError(err.message, "err"); instance.props.onError(err.message, "err");
instance.setState({ instance.setState({
title: "Not found", title: "Not found",
@@ -4003,7 +4002,6 @@
me.startMetaQuery(). me.startMetaQuery().
withLaterSub(). withLaterSub().
withDesc(). withDesc().
withTags().
build() build()
).catch(function(err){ ).catch(function(err){
localStorage.removeItem("auth-token"); localStorage.removeItem("auth-token");
@@ -4052,7 +4050,7 @@
this.setState({contactsSearchQuery: fnd.private ? fnd.private.toString() : ''}); this.setState({contactsSearchQuery: fnd.private ? fnd.private.toString() : ''});
this.tnFndSubsUpdated(); this.tnFndSubsUpdated();
} else { } else {
fnd.subscribe(fnd.startMetaQuery().withSub().withLaterDesc().build()).catch(function(err){ fnd.subscribe(fnd.startMetaQuery().withSub().withLaterDesc().withTags().build()).catch(function(err){
instance.handleError(err.message, "err"); instance.handleError(err.message, "err");
}); });
} }
@@ -4226,13 +4224,13 @@
handleNewTopicRequest: function(peerName, pub, priv, tags) { handleNewTopicRequest: function(peerName, pub, priv, tags) {
var instance = this; var instance = this;
var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic(); var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic();
var query = topic.startMetaQuery().withDesc().withSub().withData().withTags().build(); var query = topic.startMetaQuery().withDesc().withSub().withData();
var setParams; var setParams;
if (!peerName) { if (!peerName) {
query = query.withTags();
setParams = {desc: {public: pub, private: priv}, tags: tags}; setParams = {desc: {public: pub, private: priv}, tags: tags};
} }
topic.subscribe(query.build(), setParams).then(function() {
topic.subscribe(query, setParams).then(function() {
window.location.hash = setUrlSidePanel(window.location.hash, 'contacts'); window.location.hash = setUrlSidePanel(window.location.hash, 'contacts');
instance.handleTopicSelected(topic.name, undefined, Tinode.isTopicOnline(topic.name), topic.getAccessMode()); instance.handleTopicSelected(topic.name, undefined, Tinode.isTopicOnline(topic.name), topic.getAccessMode());
}).catch(function(err) { }).catch(function(err) {