bug fixes in creating topic with tags

This commit is contained in:
or-else
2018-05-03 10:52:54 -07:00
parent 82cc9ebb09
commit 09a1b85e86
+13 -5
View File
@@ -962,6 +962,9 @@
handleFocusLost: function() { handleFocusLost: function() {
this.setState({focused: false}); this.setState({focused: false});
if (this.props.onFocusLost) {
this.props.onFocusLost(this.state.input);
}
}, },
handleKeyDown: function(e) { handleKeyDown: function(e) {
@@ -1647,7 +1650,7 @@
}; };
}, },
componentWillReceiveProps: function(nextProps){ componentWillReceiveProps: function(nextProps) {
this.setState({tags: nextProps.tags}); this.setState({tags: nextProps.tags});
}, },
@@ -1675,10 +1678,11 @@
var tags = this.state.tags.slice(0); var tags = this.state.tags.slice(0);
tags.push(tag); tags.push(tag);
this.setState({tags: tags, tagInput: ''}); this.setState({tags: tags, tagInput: ''});
}
if (this.props.onTagsChanged) { if (this.props.onTagsChanged) {
this.props.onTagsChanged(tags); this.props.onTagsChanged(tags);
} }
}
}, },
handleRemoveTag: function(tag, index) { handleRemoveTag: function(tag, index) {
@@ -1695,6 +1699,9 @@
var inp = this.state.tagInput.trim(); var inp = this.state.tagInput.trim();
if (inp.length > 0) { if (inp.length > 0) {
tags.push(inp); tags.push(inp);
if (this.props.onTagsChanged) {
this.props.onTagsChanged(tags);
}
} }
this.props.onSubmit(tags); this.props.onSubmit(tags);
this.setState({activated: false, tagInput: '', tags: this.props.tags}); this.setState({activated: false, tagInput: '', tags: this.props.tags});
@@ -1733,6 +1740,7 @@
avatarDisabled={true} avatarDisabled={true}
prompt={this.state.noTagsMessage} prompt={this.state.noTagsMessage}
onEnter={this.handleAddTag} onEnter={this.handleAddTag}
onFocusLost={this.handleAddTag}
onCancel={this.handleCancel} onCancel={this.handleCancel}
onChipRemoved={this.handleRemoveTag} onChipRemoved={this.handleRemoveTag}
filterFunc={this.handleTagInput} /> filterFunc={this.handleTagInput} />
@@ -2336,7 +2344,7 @@
onImageChanged={this.handleImageChanged} /> onImageChanged={this.handleImageChanged} />
</div> </div>
<TagManager <TagManager
tags={[]} tags={this.state.tags}
activated={true} activated={true}
onTagsChanged={this.handleTagsChanged} onTagsChanged={this.handleTagsChanged}
title="Optional tags (search and discovery)" /> title="Optional tags (search and discovery)" />
@@ -4215,13 +4223,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(); var query = topic.startMetaQuery().withDesc().withSub().withData().withTags().build();
var setParams; var setParams;
if (!peerName) { if (!peerName) {
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) {