Improved chat state update.

This commit is contained in:
Martin Edenhofer 2016-01-06 14:25:53 +01:00
parent f5fa05bf96
commit a406f962ea
2 changed files with 19 additions and 6 deletions

View file

@ -38,7 +38,7 @@ class App.CustomerChat extends App.Controller
App.Collection.loadAssets(data.assets)
@meta = data
@updateMeta()
if @pushStateIntervalOn is undefined
if data.active is true
@startPushState()
)
@ -213,7 +213,14 @@ class App.CustomerChat extends App.Controller
msg = 'To be able to chat you need to select min. one chat topic below!'
# open modal settings
@settings(settings: msg)
@settings(
errors:
settings: msg
active: @meta.active
)
@meta.active = false
@pushState()
else
@stopPushState()
@pushState()
@ -277,10 +284,11 @@ class App.CustomerChat extends App.Controller
App.WebSocket.send(event:'chat_session_start')
@idleTimeoutStop()
settings: (errors = {}) ->
settings: (params = {}) ->
new Setting(
windowSpace: @
errors: errors
errors: params.errors
active: params.active
)
idleTimeoutStart: =>
@ -646,7 +654,7 @@ class Setting extends App.ControllerModal
App.view('customer_chat/setting')(
chats: App.Chat.all()
preferences: preferences
errors: @errors
errors: @errors || {}
)
submit: (e) =>
@ -670,6 +678,11 @@ class Setting extends App.ControllerModal
)
success: (data, status, xhr) =>
if @active is true || @active is false
@windowSpace.meta.active = @active
@windowSpace.pushState()
else
App.WebSocket.send(event:'chat_status_agent')
App.User.full(
App.Session.get('id'),
=>

View file

@ -178,7 +178,7 @@ optional you can ignore it for dedecated user
def self.broadcast_agent_state_update(ignore_user_id = nil)
# send broadcast to agents
Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 15.minutes).each {|item|
Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 8.hours).each {|item|
next if item.updated_by_id == ignore_user_id
data = {
event: 'chat_status_agent',