Do not highlight waiting chats if all chat seeds are full.

This commit is contained in:
Martin Edenhofer 2015-11-12 15:15:15 +01:00
parent 275ab9a931
commit d35f221017
2 changed files with 10 additions and 5 deletions

View file

@ -106,7 +106,7 @@ class App.CustomerChat extends App.Controller
@delay(delay, 200, 'updateNavMenu') @delay(delay, 200, 'updateNavMenu')
updateMeta: => updateMeta: =>
if @meta.waiting_chat_count if @meta.waiting_chat_count && @maxChats > @currentChatCount()
@$('.js-acceptChat').addClass('is-clickable is-blinking') @$('.js-acceptChat').addClass('is-clickable is-blinking')
else else
@$('.js-acceptChat').removeClass('is-clickable is-blinking') @$('.js-acceptChat').removeClass('is-clickable is-blinking')
@ -114,9 +114,11 @@ class App.CustomerChat extends App.Controller
@$('.js-badgeChattingCustomers').text(@meta.running_chat_count) @$('.js-badgeChattingCustomers').text(@meta.running_chat_count)
@$('.js-badgeActiveAgents').text(@meta.active_agents) @$('.js-badgeActiveAgents').text(@meta.active_agents)
# reopen chats
if @meta.active_sessions if @meta.active_sessions
for session in @meta.active_sessions for session in @meta.active_sessions
@addChat(session) @addChat(session)
@meta.active_sessions = false
@updateNavMenu() @updateNavMenu()
@ -134,19 +136,22 @@ class App.CustomerChat extends App.Controller
removeChat: (session_id) => removeChat: (session_id) =>
delete @chatWindows[session_id] delete @chatWindows[session_id]
@updateMeta()
propagateLayoutChange: (event) => propagateLayoutChange: (event) =>
# adjust scroll position on layoutChange # adjust scroll position on layoutChange
for session_id, chat of @chatWindows for session_id, chat of @chatWindows
chat.trigger 'layout-changed' chat.trigger 'layout-changed'
acceptChat: => currentChatCount: =>
currentChats = 0 currentChats = 0
for key, value of @chatWindows for key, value of @chatWindows
if @chatWindows[key] if @chatWindows[key]
currentChats += 1 currentChats += 1
return if currentChats >= @maxChats currentChats
acceptChat: =>
return if @currentChatCount() >= @maxChats
App.WebSocket.send(event:'chat_session_start') App.WebSocket.send(event:'chat_session_start')
class CustomerChatRouter extends App.ControllerPermanent class CustomerChatRouter extends App.ControllerPermanent
@ -410,7 +415,7 @@ class chatWindow extends App.Controller
time: time time: time
addStatusMessage: (message) -> addStatusMessage: (message) ->
@body.append App.view('customer_chat/customer_chat_status_message') @body.append App.view('customer_chat/chat_status_message')
message: message message: message
@scrollToBottom() @scrollToBottom()

View file

@ -157,7 +157,7 @@ class Chat::Session < ApplicationModel
preferences[:participants] preferences[:participants]
end end
def send_to_recipients(message, ignore_client_id) def send_to_recipients(message, ignore_client_id = nil)
preferences[:participants].each {|local_client_id| preferences[:participants].each {|local_client_id|
next if local_client_id == ignore_client_id next if local_client_id == ignore_client_id
Sessions.send(local_client_id, message) Sessions.send(local_client_id, message)