Fixed typing issues.
This commit is contained in:
parent
526a1eed81
commit
6dbb5cb078
2 changed files with 13 additions and 18 deletions
|
@ -233,6 +233,7 @@ class ChatWindow extends App.Controller
|
||||||
@lastTimestamp
|
@lastTimestamp
|
||||||
@lastAddedType
|
@lastAddedType
|
||||||
@isTyping = false
|
@isTyping = false
|
||||||
|
@isAgentTyping = false
|
||||||
@resetUnreadMessages()
|
@resetUnreadMessages()
|
||||||
|
|
||||||
@on 'layout-change', @scrollToBottom
|
@on 'layout-change', @scrollToBottom
|
||||||
|
@ -319,6 +320,10 @@ class ChatWindow extends App.Controller
|
||||||
ENTERKEY = 13
|
ENTERKEY = 13
|
||||||
|
|
||||||
if event.keyCode isnt TABKEY && event.keyCode isnt ENTERKEY
|
if event.keyCode isnt TABKEY && event.keyCode isnt ENTERKEY
|
||||||
|
|
||||||
|
# send typing start event only every 1.4 seconds
|
||||||
|
return if @isAgentTyping && @isAgentTyping > new Date(new Date().getTime() - 1400)
|
||||||
|
@isAgentTyping = new Date()
|
||||||
App.WebSocket.send(
|
App.WebSocket.send(
|
||||||
event:'chat_session_typing'
|
event:'chat_session_typing'
|
||||||
data:
|
data:
|
||||||
|
@ -413,7 +418,7 @@ class ChatWindow extends App.Controller
|
||||||
@scrollToBottom()
|
@scrollToBottom()
|
||||||
|
|
||||||
# clear old delay, set new
|
# clear old delay, set new
|
||||||
@delay(@removeWritingLoader, 1800, 'typing')
|
@delay(@removeWritingLoader, 2000, 'typing')
|
||||||
|
|
||||||
removeWritingLoader: =>
|
removeWritingLoader: =>
|
||||||
@isTyping = false
|
@isTyping = false
|
||||||
|
|
|
@ -209,23 +209,15 @@ do($ = window.jQuery, window) ->
|
||||||
|
|
||||||
sessionStorage.setItem 'unfinished_message', @input.val()
|
sessionStorage.setItem 'unfinished_message', @input.val()
|
||||||
|
|
||||||
@onTypingStart()
|
@onTyping()
|
||||||
|
|
||||||
onTypingStart: ->
|
onTyping: ->
|
||||||
|
|
||||||
clearTimeout(@isTypingTimeout) if @isTypingTimeout
|
# send typing start event only every 1.5 seconds
|
||||||
|
return if @isTyping && @isTyping > new Date(new Date().getTime() - 1500)
|
||||||
# fire typingEnd after 5 seconds
|
@isTyping = new Date()
|
||||||
@isTypingTimeout = setTimeout @onTypingEnd, 1500
|
@send 'chat_session_typing',
|
||||||
|
session_id: @sessionId
|
||||||
# send typing start event
|
|
||||||
if !@isTyping
|
|
||||||
@isTyping = true
|
|
||||||
@send 'chat_session_typing',
|
|
||||||
session_id: @sessionId
|
|
||||||
|
|
||||||
onTypingEnd: =>
|
|
||||||
@isTyping = false
|
|
||||||
|
|
||||||
onSubmit: (event) =>
|
onSubmit: (event) =>
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -256,8 +248,6 @@ do($ = window.jQuery, window) ->
|
||||||
@input.val('')
|
@input.val('')
|
||||||
@scrollToBottom()
|
@scrollToBottom()
|
||||||
|
|
||||||
@isTyping = false
|
|
||||||
|
|
||||||
# send message event
|
# send message event
|
||||||
@send 'chat_session_message',
|
@send 'chat_session_message',
|
||||||
content: message
|
content: message
|
||||||
|
|
Loading…
Reference in a new issue