From 61cb35c193952fde72ce1df42d4151e96ffffcbc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 12 Nov 2015 16:58:47 +0100 Subject: [PATCH 1/2] Update ws client ids in reconnect. --- lib/sessions/event/chat_status_customer.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sessions/event/chat_status_customer.rb b/lib/sessions/event/chat_status_customer.rb index 8dc46d567..5fa937e22 100644 --- a/lib/sessions/event/chat_status_customer.rb +++ b/lib/sessions/event/chat_status_customer.rb @@ -17,6 +17,10 @@ class Sessions::Event::ChatStatusCustomer < Sessions::Event::ChatBase session_id = nil if @data['data']['session_id'] session_id = @data['data']['session_id'] + + # update recipients of existing sessions + chat_session = Chat::Session.find_by(session_id: session_id) + chat_session.add_recipient(@client_id, true) end { event: 'chat_status_customer', From 6b4c6ab12ab48b7076733a4495141e9cdf000edd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 12 Nov 2015 17:15:58 +0100 Subject: [PATCH 2/2] In reopenSesssion, scroll to bottom. Remove sessionID on close. --- public/assets/chat/chat.coffee | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/public/assets/chat/chat.coffee b/public/assets/chat/chat.coffee index 8098412da..5b40adca8 100644 --- a/public/assets/chat/chat.coffee +++ b/public/assets/chat/chat.coffee @@ -138,7 +138,7 @@ do($ = window.jQuery, window) -> @onConnectionEstablished(data) for message in data.session - @log 'debug', "message in session", message + @log 'debug', 'message in session', message @renderMessage message: message.content id: message.id @@ -149,6 +149,7 @@ do($ = window.jQuery, window) -> @show() @open() + @scrollToBottom() if unfinishedMessage @input.focus() @@ -256,7 +257,7 @@ do($ = window.jQuery, window) -> close: (event) => event.stopPropagation() if event - @ws.close() + #@ws.close() sessionStorage.removeItem 'sessionId' sessionStorage.removeItem 'unfinished_message' @@ -275,6 +276,8 @@ do($ = window.jQuery, window) -> @send 'chat_session_close', session_id: @sessionId + @setSessionId undefined + hide: -> @el.removeClass('zammad-chat-is-visible') @@ -427,7 +430,10 @@ do($ = window.jQuery, window) -> setSessionId: (id) => @sessionId = id - sessionStorage.setItem 'sessionId', id + if id is undefined + sessionStorage.removeItem 'sessionId' + else + sessionStorage.setItem 'sessionId', id onConnectionEstablished: (data) =>