Added error prompt on empty user search

This commit is contained in:
Rohan Sircar 2020-06-20 13:48:55 +05:30
parent 2addcc1fa8
commit a9d81fce19
2 changed files with 18 additions and 14 deletions

View File

@ -175,7 +175,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
const msgTime = new Date(); const msgTime = new Date();
const context: ChatMessageViewModel = { const context: ChatMessageViewModel = {
fromUser: JsonAPI.principleName, fromUser: JsonAPI.principleName,
toUser: "", toUser: contactName,
message: messageContent, message: messageContent,
messageTime: msgTime, messageTime: msgTime,
}; };
@ -192,12 +192,12 @@ export class ChatView implements Observer<ChatMessageViewModel> {
fromUser: JsonAPI.principleName, fromUser: JsonAPI.principleName,
toUser: contactName, toUser: contactName,
messageCipher: messageCipher, messageCipher: messageCipher,
messageTime: msgTime, messageTime: msgTime.toISOString(),
}; };
this._sendMessageAJAX(chatMessageDTO); this._sendMessageAJAX(chatMessageDTO);
} }
private _sendMessageAJAX(chatMessageDTO: ChatMessageDTO): void { private _sendMessageAJAX(chatMessageDTO: any): void {
let headers = new Headers(); let headers = new Headers();
// console.log("Token = " + btoa("hmm" + ":" + "hmm")) // console.log("Token = " + btoa("hmm" + ":" + "hmm"))

View File

@ -165,17 +165,22 @@ export class UserView implements Observer<ActiveUserViewModel> {
e.preventDefault(); e.preventDefault();
// log.trace(temp); // log.trace(temp);
const searchTerm = this._userSearchInputElement.value; const searchTerm = this._userSearchInputElement.value;
log.debug("search term value = " + searchTerm); if (searchTerm.length > 0) {
const list = this._model.activeUsersList; log.debug("search term value = " + searchTerm);
log.debug("active users"); const list = this._model.activeUsersList;
log.debug(list); log.debug("active users");
if (list == null) { log.debug(list);
log.error("Users list is null"); if (!list) {
return; log.error("Users list is null");
return;
}
let searchResult = this._searchService.search(list, searchTerm);
this.update({ data: searchResult, op: "" });
log.debug(searchResult);
}
else {
this._notificationService.error("Please enter a name")
} }
let searchResult = this._searchService.search(list, searchTerm);
this.update({ data: searchResult, op: "" });
log.debug(searchResult);
}); });
} }
@ -183,7 +188,6 @@ export class UserView implements Observer<ActiveUserViewModel> {
this._userSearchInputElement.addEventListener("input", (e) => { this._userSearchInputElement.addEventListener("input", (e) => {
e.preventDefault(); e.preventDefault();
if (this._userSearchInputElement.value.length < 2) { if (this._userSearchInputElement.value.length < 2) {
log.debug("inputted");
this._userSearchCancelButton.hidden = false; this._userSearchCancelButton.hidden = false;
} }
}); });