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

View file

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