@@ -431,20 +128,29 @@ class Chat extends LitElement {
this.openPrivateMessage = false;
} }
style=${this.openPrivateMessage ? "display: block" : "display: none"}>
-
+
-
+
-
${translate("chatpage.cchange6")}
-
+
+
+
+
+
+
+
+
+ ${this.userFound.length > 0 ? (
+ html`
+ console.log('user selected')}
+ .searchResults=${this.userFound}
+ ?loading=${this.isLoading}>
+
+ `
+ ) : null}
+
@@ -535,9 +252,23 @@ class Chat extends LitElement {
return false;
}
- this.shadowRoot.getElementById('sendTo').addEventListener('keydown', stopKeyEventPropagation);
+ const nameInput = this.shadowRoot.getElementById('sendTo');
+
+ nameInput.addEventListener('keydown', stopKeyEventPropagation);
this.shadowRoot.getElementById('messageBox').addEventListener('keydown', stopKeyEventPropagation);
+ // let typingTimer;
+ // let doneTypingInterval = 3000;
+
+ // //on keyup, start the countdown
+ // nameInput.addEventListener('keyup', () => {
+ // clearTimeout(typingTimer);
+ // if (nameInput.value) {
+ // console.log("typing started!");
+ // typingTimer = setTimeout(this.userSearch, doneTypingInterval);
+ // }
+ // });
+
const getDataFromURL = () => {
let tempUrl = document.location.href
let splitedUrl = decodeURI(tempUrl).split('?')
@@ -637,6 +368,28 @@ class Chat extends LitElement {
parentEpml.imReady()
}
+ async updated(changedProperties) {
+ if (changedProperties && changedProperties.has('userFound')) {
+ console.log(this.userFound, "user found array here");
+ }
+ }
+
+ async userSearch() {
+ try {
+ let result = await parentEpml.request('apiCall', {
+ type: 'api',
+ url: `/names/${this.shadowRoot.getElementById('sendTo').value}`
+ })
+ console.log({result});
+ this.userFound = [
+ ...this.userFound,
+ result.owner,
+ ];
+ } catch (error) {
+ console.error(error);
+ }
+ }
+
setChatEditor(editor) {
this.chatEditor = editor;
}