ignore click for the current topic in found contacts

This commit is contained in:
or-else
2018-09-21 13:09:59 +03:00
parent c56c91afce
commit 15393198be
3 changed files with 18 additions and 26 deletions
+5 -3
View File
@@ -4847,12 +4847,14 @@ class TinodeWeb extends React.Component {
errorText: '',
errorLevel: null,
mobilePanel: 'topic-view',
topicSelectedOnline: online,
topicSelectedAcs: acs,
showInfoPanel: false
});
// Contact selected
// Different contact selected.
if (this.state.topicSelected != topicName) {
this.setState({
topicSelectedOnline: online,
topicSelectedAcs: acs
});
navigateTo(setUrlTopic("", topicName));
}
} else {
+12 -22
View File
@@ -28679,7 +28679,6 @@ class SidepanelView extends React.Component {
chatList: this.props.chatList,
showContextMenu: this.props.showContextMenu,
onTopicSelected: this.props.onTopicSelected }) : view === 'newtpk' ? React.createElement(NewTopicView, {
contactsSearchQuery: this.props.contactsSearchQuery,
searchResults: this.props.searchResults,
onInitFind: this.props.onInitFind,
onSearchContacts: this.props.onSearchContacts,
@@ -29623,7 +29622,6 @@ class NewTopicView extends React.Component {
this.state = {
tabSelected: "p2p",
searchQuery: props.contactsSearchQuery,
contactList: props.searchResults
};
@@ -29639,7 +29637,6 @@ class NewTopicView extends React.Component {
static getDerivedStateFromProps(nextProps, prevState) {
return {
searchQuery: nextProps.contactsSearchQuery,
contactList: nextProps.searchResults
};
}
@@ -29708,7 +29705,6 @@ class NewTopicView extends React.Component {
'div',
{ className: 'flex-column' },
React.createElement(SearchContacts, { type: 'p2p',
searchQuery: this.state.searchQuery,
onSearchContacts: this.props.onSearchContacts }),
React.createElement(ContactList, {
contacts: this.state.contactList,
@@ -29818,13 +29814,13 @@ class NewTopicGroup extends React.PureComponent {
}
};
class SearchContacts extends React.Component {
class SearchContacts extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
edited: false,
search: props.searchQuery
search: ''
};
this.handleSearchChange = this.handleSearchChange.bind(this);
@@ -29834,8 +29830,8 @@ class SearchContacts extends React.Component {
}
componentWillUnmount() {
if (this.state.search) {
this.setState({ search: '' });
if (this.state.edited) {
this.setState({ search: '', edited: false });
this.props.onSearchContacts(Tinode.DEL_CHAR);
}
}
@@ -29847,16 +29843,12 @@ class SearchContacts extends React.Component {
handleSearch(e) {
e.preventDefault();
var query = this.state.search.trim();
if (query.length > 0) {
this.setState({ edited: true });
this.props.onSearchContacts(query);
} else if (this.props.searchQuery) {
this.props.onSearchContacts(Tinode.DEL_CHAR);
}
this.setState({ edited: query.length > 0 });
this.props.onSearchContacts(query.length > 0 ? query : Tinode.DEL_CHAR);
}
handleClear() {
if (this.state.edited || this.state.search) {
if (this.state.edited) {
this.props.onSearchContacts(Tinode.DEL_CHAR);
}
this.setState({ search: '', edited: false });
@@ -31988,7 +31980,6 @@ class TinodeWeb extends React.Component {
contextMenuParams: null,
contextMenuItems: [],
contactsSearchQuery: '',
// Chats as shown in the ContactsView
chatList: [],
// Contacts returned by a search query.
@@ -32401,7 +32392,6 @@ class TinodeWeb extends React.Component {
tnInitFind() {
let fnd = this.tinode.getFndTopic();
if (fnd.isSubscribed()) {
this.setState({ contactsSearchQuery: '' });
this.tnFndSubsUpdated();
} else {
fnd.onSubsUpdated = this.tnFndSubsUpdated;
@@ -32428,7 +32418,6 @@ class TinodeWeb extends React.Component {
*/
handleSearchContacts(query) {
var fnd = this.tinode.getFndTopic();
this.setState({ contactsSearchQuery: query == Tinode.DEL_CHAR ? '' : query });
fnd.setMeta({ desc: { public: query } }).then(ctrl => {
return fnd.getMeta(fnd.startMetaQuery().withSub().build());
}).catch(err => {
@@ -32443,12 +32432,14 @@ class TinodeWeb extends React.Component {
errorText: '',
errorLevel: null,
mobilePanel: 'topic-view',
topicSelectedOnline: online,
topicSelectedAcs: acs,
showInfoPanel: false
});
// Contact selected
// Different contact selected.
if (this.state.topicSelected != topicName) {
this.setState({
topicSelectedOnline: online,
topicSelectedAcs: acs
});
navigateTo(setUrlTopic("", topicName));
}
} else {
@@ -32881,7 +32872,6 @@ class TinodeWeb extends React.Component {
onValidateCredentials: this.handleValidateCredentialsRequest,
onInitFind: this.tnInitFind,
contactsSearchQuery: this.state.contactsSearchQuery,
searchResults: this.state.searchResults,
onSearchContacts: this.handleSearchContacts,
+1 -1
View File
File diff suppressed because one or more lines are too long