Feature: Typing Indicator on widget and dashboard (#811)

* Adds typing indicator for widget
* typing indicator for agents in dashboard

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Nithin David Thomas 2020-05-04 23:07:56 +05:30 committed by GitHub
parent fabc3170b7
commit 5bc8219db5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 663 additions and 78 deletions

View file

@ -6,6 +6,8 @@ class ActionCableConnector extends BaseActionCableConnector {
this.events = {
'message.created': this.onMessageCreated,
'message.updated': this.onMessageUpdated,
'conversation.typing_on': this.onTypingOn,
'conversation.typing_off': this.onTypingOff,
};
}
@ -16,6 +18,35 @@ class ActionCableConnector extends BaseActionCableConnector {
onMessageUpdated = data => {
this.app.$store.dispatch('conversation/updateMessage', data);
};
onTypingOn = () => {
this.clearTimer();
this.app.$store.dispatch('conversation/toggleAgentTyping', {
status: 'on',
});
this.initTimer();
};
onTypingOff = () => {
this.clearTimer();
this.app.$store.dispatch('conversation/toggleAgentTyping', {
status: 'off',
});
};
clearTimer = () => {
if (this.CancelTyping) {
clearTimeout(this.CancelTyping);
this.CancelTyping = null;
}
};
initTimer = () => {
// Turn off typing automatically after 30 seconds
this.CancelTyping = setTimeout(() => {
this.onTypingOff();
}, 30000);
};
}
export const refreshActionCableConnector = pubsubToken => {