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