Skip to content

Node.js based forum software built for the modern web

hopefully I got everything right this time!!

pichalite44d4c2bc7c65
diff --git a/public/src/client/chats.js b/public/src/client/chats.js
index 83a867516e..a85d527b0a 100644
--- a/public/src/client/chats.js
+++ b/public/src/client/chats.js
@@ -548,55 +548,54 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
function doSearch() {
var username = components.get('chat/search').val();
var chatsListEl = $('[component="chat/search/list"]');
-
- if(username) {
- socket.emit('user.search', {
+
+ if (!username) {
+ return chatsListEl.empty();
+ }
+
+ socket.emit('user.search', {
query: username,
searchBy: 'username'
- }, function(err, data) {
- if (err) {
- return app.alertError(err.message);
- }
+ }, function(err, data) {
+ if (err) {
+ return app.alertError(err.message);
+ }
- chatsListEl.empty();
+ chatsListEl.empty();
- if (data.users.length === 0) {
- chatsListEl.append('<li><div><span>No users found!</span></div></li>');
- } else {
- data.users.forEach(function(userObj) {
- function createUserImage() {
- return (userObj.picture ?
- '<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
- '<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
- '<i class="fa fa-circle status ' + userObj.status + '"></i> ' +
- userObj.username;
- }
+ if (data.users.length === 0) {
+ chatsListEl.translateHtml('<li><div><span>[[users:no-users-found]]</span></div></li>');
+ } else {
+ data.users.forEach(function(userObj) {
+ function createUserImage() {
+ return (userObj.picture ?
+ '<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
+ '<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
+ '<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
+ }
- var chatEl = $('<li component="chat/search/user" />')
- .attr('data-uid', userObj.uid)
- .appendTo(chatsListEl);
+ var chatEl = $('<li component="chat/search/user" />')
+ .attr('data-uid', userObj.uid)
+ .appendTo(chatsListEl);
- chatEl.append(createUserImage());
+ chatEl.append(createUserImage());
- chatEl.click(function() {
- socket.emit('modules.chats.hasPrivateChat', userObj.uid, function(err, roomId) {
- if (err) {
- return app.alertError(err.message);
- }
- if (roomId) {
- ajaxify.go('chats/' + roomId);
- } else {
- app.newChat(userObj.uid);
- }
- });
- });
+ chatEl.click(function() {
+ socket.emit('modules.chats.hasPrivateChat', userObj.uid, function(err, roomId) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ if (roomId) {
+ ajaxify.go('chats/' + roomId);
+ } else {
+ app.newChat(userObj.uid);
+ }
+ });
});
- }
+ });
+ }
- });
- } else {
- chatsListEl.empty();
- }
+ });
}
};
return Chats;