show different message when search returned no contacts

This commit is contained in:
or-else
2019-11-08 17:43:41 +03:00
parent 1cdb8b724c
commit 4c28753e6a
12 changed files with 142 additions and 79 deletions
+2 -2
View File
@@ -69,8 +69,8 @@ export const MAX_IMAGE_DIM = 768;
// hidden under "+X more" // hidden under "+X more"
export const MAX_ONLINE_IN_TOPIC = 4; export const MAX_ONLINE_IN_TOPIC = 4;
// Maximum length of topic title (and Private comment) or user name. // Maximum length of user name, topic title, and private comment.
export const MAX_TITLE_LENGTH = 40; export const MAX_TITLE_LENGTH = 60;
// Link for "Contact Us". // Link for "Contact Us".
export const LINK_CONTACT_US = 'email:info@tinode.co'; export const LINK_CONTACT_US = 'email:info@tinode.co';
+2 -1
View File
@@ -61,10 +61,11 @@
"messages_not_readable": "no access to messages", "messages_not_readable": "no access to messages",
"peers_messaging_disabled": "Peer's messaging is disabled.", "peers_messaging_disabled": "Peer's messaging is disabled.",
"enable_peers_messaging": "Enable", "enable_peers_messaging": "Enable",
"search_for_contacts": "Use search to find contacts",
"search_no_results": "Search returned no results",
"tabtitle_find_user": "find", "tabtitle_find_user": "find",
"tabtitle_new_group": "new group", "tabtitle_new_group": "new group",
"tabtitle_group_by_id": "by id", "tabtitle_group_by_id": "by id",
"search_for_contacts": "Use search to find contacts",
"new_password_placeholder": "Enter new password", "new_password_placeholder": "Enter new password",
"label_reset_password": "Send a password reset email:", "label_reset_password": "Send a password reset email:",
"credential_email_prompt": "Your registration email", "credential_email_prompt": "Your registration email",
+3 -2
View File
@@ -147,6 +147,7 @@
"report_chat_warning": "Вы действительно хотите сообщить о нарушении и заблокировать этот чат?", "report_chat_warning": "Вы действительно хотите сообщить о нарушении и заблокировать этот чат?",
"action_clear_messages": "Удалить сообщения", "action_clear_messages": "Удалить сообщения",
"clear_messages_warning": "Вы действительно хотите удалить все сообщения в чате? Их будет невозможно восстановить.", "clear_messages_warning": "Вы действительно хотите удалить все сообщения в чате? Их будет невозможно восстановить.",
"topic_delete_warning": ":!![MISSING]!!:Are you sure you want to delete this conversation?", "topic_delete_warning": "Вы действительно хотите удалить этот чат?",
"topic_block_warning": ":!![MISSING]!!:Are you sure you want to block this conversation?" "topic_block_warning": "Вы действительно хотите заблокировать этот чат?",
"search_no_results": "Ничего не найдено"
} }
+3 -2
View File
@@ -140,7 +140,7 @@
"link_privacy_policy": "隐私政策", "link_privacy_policy": "隐私政策",
"action_delete_messages": "删除所有帖子", "action_delete_messages": "删除所有帖子",
"action_block_contact": "屏蔽联系人", "action_block_contact": "屏蔽联系人",
"delete_messages_warning": ":!![MISSING]!!:Are you sure you want to delete all mesages? It cannot be undone.", "delete_messages_warning": ":!![MISSING]!!:Are you sure you want to delete all messages? It cannot be undone.",
"leave_chat_warning": ":!![MISSING]!!:Are you sure you want to leave this conversation.", "leave_chat_warning": ":!![MISSING]!!:Are you sure you want to leave this conversation.",
"block_contact_warning": ":!![MISSING]!!:Are you sure you want to block this contact?", "block_contact_warning": ":!![MISSING]!!:Are you sure you want to block this contact?",
"action_report_chat": "检举垃圾邮件", "action_report_chat": "检举垃圾邮件",
@@ -148,5 +148,6 @@
"action_clear_messages": ":!![MISSING]!!:Clear Messages", "action_clear_messages": ":!![MISSING]!!:Clear Messages",
"clear_messages_warning": ":!![MISSING]!!:Are you sure you want to clear all messages? It cannot be undone.", "clear_messages_warning": ":!![MISSING]!!:Are you sure you want to clear all messages? It cannot be undone.",
"topic_delete_warning": ":!![MISSING]!!:Are you sure you want to delete this conversation?", "topic_delete_warning": ":!![MISSING]!!:Are you sure you want to delete this conversation?",
"topic_block_warning": ":!![MISSING]!!:Are you sure you want to block this conversation?" "topic_block_warning": ":!![MISSING]!!:Are you sure you want to block this conversation?",
"search_no_results": ":!![MISSING]!!:Search returned no results"
} }
+6 -2
View File
@@ -62,10 +62,11 @@
"messages_not_readable": "no access to messages", "messages_not_readable": "no access to messages",
"peers_messaging_disabled": "Peer's messaging is disabled.", "peers_messaging_disabled": "Peer's messaging is disabled.",
"enable_peers_messaging": "Enable", "enable_peers_messaging": "Enable",
"search_for_contacts": "Use search to find contacts",
"search_no_results": "Search returned no results",
"tabtitle_find_user": "find", "tabtitle_find_user": "find",
"tabtitle_new_group": "new group", "tabtitle_new_group": "new group",
"tabtitle_group_by_id": "by id", "tabtitle_group_by_id": "by id",
"search_for_contacts": "Use search to find contacts",
"new_password_placeholder": "Enter new password", "new_password_placeholder": "Enter new password",
"label_reset_password": "Send a password reset email:", "label_reset_password": "Send a password reset email:",
"credential_email_prompt": "Your registration email", "credential_email_prompt": "Your registration email",
@@ -299,7 +300,10 @@
"block_contact_warning": "Вы действительно заблокировать этот контакт?", "block_contact_warning": "Вы действительно заблокировать этот контакт?",
"report_chat_warning": "Вы действительно хотите сообщить о нарушении и заблокировать этот чат?", "report_chat_warning": "Вы действительно хотите сообщить о нарушении и заблокировать этот чат?",
"action_clear_messages": "Удалить сообщения", "action_clear_messages": "Удалить сообщения",
"clear_messages_warning": "Вы действительно хотите удалить все сообщения в чате? Их будет невозможно восстановить." "clear_messages_warning": "Вы действительно хотите удалить все сообщения в чате? Их будет невозможно восстановить.",
"topic_delete_warning": "Вы действительно хотите удалить этот чат?",
"topic_block_warning": "Вы действительно хотите заблокировать этот чат?",
"search_no_results": "Ничего не найдено"
}, },
"zh": { "zh": {
"archived_contacts": "已归档联系人 ({count})", "archived_contacts": "已归档联系人 ({count})",
+41 -16
View File
@@ -1,6 +1,8 @@
// Create new topic and invite users or send an invite. // Create new topic and invite users or send an invite.
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
import Tinode from 'tinode-sdk';
import ContactList from '../widgets/contact-list.jsx'; import ContactList from '../widgets/contact-list.jsx';
import NewTopicById from '../widgets/new-topic-by-id.jsx'; import NewTopicById from '../widgets/new-topic-by-id.jsx';
@@ -10,15 +12,30 @@ import SearchContacts from '../widgets/search-contacts.jsx';
import HashNavigation from '../lib/navigation.js'; import HashNavigation from '../lib/navigation.js';
import { vcard } from '../lib/utils.js'; import { vcard } from '../lib/utils.js';
export default class NewTopicView extends React.Component { const messages = defineMessages({
search_for_contacts: {
id: "search_for_contacts",
defaultMessage: "Use search to find contacts",
description: "Text shown in contacts view when user entered no search query."
},
search_no_results: {
id: "search_no_results",
defaultMessage: "Search returned no results",
description: "Text shown in contacts view when query returned no results."
}
});
class NewTopicView extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
tabSelected: 'p2p' tabSelected: 'p2p',
searchQuery: null
}; };
this.handleTabClick = this.handleTabClick.bind(this); this.handleTabClick = this.handleTabClick.bind(this);
this.handleSearchContacts = this.handleSearchContacts.bind(this);
this.handleContactSelected = this.handleContactSelected.bind(this); this.handleContactSelected = this.handleContactSelected.bind(this);
this.handleNewGroupSubmit = this.handleNewGroupSubmit.bind(this); this.handleNewGroupSubmit = this.handleNewGroupSubmit.bind(this);
this.handleGroupByID = this.handleGroupByID.bind(this); this.handleGroupByID = this.handleGroupByID.bind(this);
@@ -34,6 +51,11 @@ export default class NewTopicView extends React.Component {
this.setState({tabSelected: e.currentTarget.dataset.id}); this.setState({tabSelected: e.currentTarget.dataset.id});
} }
handleSearchContacts(query) {
this.props.onSearchContacts(query);
this.setState({searchQuery: Tinode.isNullValue(query) ? null : query});
}
handleContactSelected(sel) { handleContactSelected(sel) {
if (this.state.tabSelected === 'p2p') { if (this.state.tabSelected === 'p2p') {
HashNavigation.navigateTo(HashNavigation.removeUrlParam(window.location.hash, 'tab')); HashNavigation.navigateTo(HashNavigation.removeUrlParam(window.location.hash, 'tab'));
@@ -52,6 +74,9 @@ export default class NewTopicView extends React.Component {
} }
render() { render() {
const {formatMessage} = this.props.intl;
const no_contacts_placeholder = formatMessage(this.state.searchQuery ?
messages.search_no_results : messages.search_for_contacts);
return ( return (
<div className="flex-column"> <div className="flex-column">
<ul className="tabbar"> <ul className="tabbar">
@@ -81,21 +106,21 @@ export default class NewTopicView extends React.Component {
onSubmit={this.handleGroupByID} onSubmit={this.handleGroupByID}
onError={this.props.onError} /> : onError={this.props.onError} /> :
<div className="flex-column"> <div className="flex-column">
<SearchContacts type="p2p" <SearchContacts
onSearchContacts={this.props.onSearchContacts} /> type="p2p"
<FormattedMessage id="search_for_contacts" defaultMessage="Use search to find contacts" onSearchContacts={this.handleSearchContacts} />
description="Prompt in search field.">{ <ContactList
(search_for_contacts) => <ContactList contacts={this.props.searchResults}
contacts={this.props.searchResults} myUserId={this.props.myUserId}
myUserId={this.props.myUserId} emptyListMessage={no_contacts_placeholder}
emptyListMessage={search_for_contacts} showOnline={false}
showOnline={false} showUnread={false}
showUnread={false} showContextMenu={false}
showContextMenu={false} onTopicSelected={this.handleContactSelected} />
onTopicSelected={this.handleContactSelected} />
}</FormattedMessage>
</div>} </div>}
</div> </div>
); );
} }
}; };
export default injectIntl(NewTopicView);
+53 -35
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+28 -15
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long