Fixed issue #1012 - Gui stuck / Error on random switching through overviews.
This commit is contained in:
parent
7a1df2e400
commit
9f990f8352
5 changed files with 63 additions and 10 deletions
|
@ -921,7 +921,7 @@ class Table extends App.Controller
|
||||||
# get ticket list
|
# get ticket list
|
||||||
ticketListShow = []
|
ticketListShow = []
|
||||||
for ticket in tickets
|
for ticket in tickets
|
||||||
ticketListShow.push App.Ticket.fullLocal(ticket.id)
|
ticketListShow.push App.Ticket.find(ticket.id)
|
||||||
|
|
||||||
# if customer and no ticket exists, show the following message only
|
# if customer and no ticket exists, show the following message only
|
||||||
if !ticketListShow[0] && @permissionCheck('ticket.customer')
|
if !ticketListShow[0] && @permissionCheck('ticket.customer')
|
||||||
|
|
|
@ -8,12 +8,12 @@ class App.Session
|
||||||
@get: ( key ) ->
|
@get: ( key ) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _sessionSingleton
|
_instance ?= new _sessionSingleton
|
||||||
_instance.get( key )
|
_instance.get(key)
|
||||||
|
|
||||||
@set: ( user ) ->
|
@set: ( user ) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _sessionSingleton
|
_instance ?= new _sessionSingleton
|
||||||
_instance.set( user )
|
_instance.set(user)
|
||||||
|
|
||||||
class _sessionSingleton extends Spine.Module
|
class _sessionSingleton extends Spine.Module
|
||||||
@include App.LogInclude
|
@include App.LogInclude
|
||||||
|
|
|
@ -11,11 +11,21 @@ class Sessions::Backend::Base
|
||||||
|
|
||||||
def asset_needed?(record)
|
def asset_needed?(record)
|
||||||
class_name = record.class.to_s
|
class_name = record.class.to_s
|
||||||
if !@asset_lookup || !@asset_lookup[class_name] || !@asset_lookup[class_name][record.id] || @asset_lookup[class_name][record.id] < record.updated_at
|
if !@asset_lookup || !@asset_lookup[class_name] || !@asset_lookup[class_name][record.id]
|
||||||
if !@asset_lookup[class_name]
|
@asset_lookup[class_name] ||= {}
|
||||||
@asset_lookup[class_name] = {}
|
@asset_lookup[class_name][record.id] = {
|
||||||
|
updated_at: record.updated_at,
|
||||||
|
pushed_at: Time.zone.now,
|
||||||
|
}
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
@asset_lookup[class_name][record.id] = record.updated_at
|
|
||||||
|
if (!@asset_lookup[class_name][record.id][:updated_at] || @asset_lookup[class_name][record.id][:updated_at] < record.updated_at) ||
|
||||||
|
(!@asset_lookup[class_name][record.id][:pushed_at] || @asset_lookup[class_name][record.id][:pushed_at] > Time.zone.now - 45.seconds)
|
||||||
|
@asset_lookup[class_name][record.id] = {
|
||||||
|
updated_at: record.updated_at,
|
||||||
|
pushed_at: Time.zone.now,
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'test_helper'
|
||||||
|
|
||||||
class SessionCollectionsTest < ActiveSupport::TestCase
|
class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
test 'c collections' do
|
test 'a collections' do
|
||||||
|
|
||||||
UserInfo.current_user_id = 1
|
UserInfo.current_user_id = 1
|
||||||
|
|
||||||
|
@ -168,4 +168,43 @@ class SessionCollectionsTest < ActiveSupport::TestCase
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'b assets' do
|
||||||
|
# create users
|
||||||
|
roles = Role.where(name: %w(Agent Admin))
|
||||||
|
groups = Group.all
|
||||||
|
|
||||||
|
UserInfo.current_user_id = 2
|
||||||
|
agent1 = User.create_or_update(
|
||||||
|
login: 'sessions-assets-1',
|
||||||
|
firstname: 'Session',
|
||||||
|
lastname: "activity stream #{rand(99_999)}",
|
||||||
|
email: 'sessions-assets1@example.com',
|
||||||
|
password: 'agentpw',
|
||||||
|
active: true,
|
||||||
|
roles: roles,
|
||||||
|
groups: groups,
|
||||||
|
)
|
||||||
|
assert(agent1.save, 'create/update agent1')
|
||||||
|
|
||||||
|
assets = {}
|
||||||
|
client1 = Sessions::Backend::Collections::Group.new(agent1, assets, false, '123-1', 2)
|
||||||
|
data = client1.push
|
||||||
|
assert(data[:collection][:Group][groups.first.id])
|
||||||
|
assert(data[:assets][:Group][groups.first.id])
|
||||||
|
travel 10.seconds
|
||||||
|
|
||||||
|
client1 = Sessions::Backend::Collections::Group.new(agent1, assets, false, '123-1', 2)
|
||||||
|
data = client1.push
|
||||||
|
assert(data[:collection][:Group][groups.first.id])
|
||||||
|
assert(data[:assets][:Group][groups.first.id])
|
||||||
|
|
||||||
|
travel 2.minutes
|
||||||
|
client1 = Sessions::Backend::Collections::Group.new(agent1, assets, false, '123-1', 2)
|
||||||
|
data = client1.push
|
||||||
|
assert(data[:collection][:Group][groups.first.id])
|
||||||
|
assert_nil(data[:assets][:Group])
|
||||||
|
|
||||||
|
travel_back
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -309,7 +309,11 @@ class SessionEnhancedTest < ActiveSupport::TestCase
|
||||||
}
|
}
|
||||||
#puts "c: #{collections_result.inspect}"
|
#puts "c: #{collections_result.inspect}"
|
||||||
collections_orig.each { |key, _value|
|
collections_orig.each { |key, _value|
|
||||||
|
if collections_orig[key].nil?
|
||||||
|
assert_nil(collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})")
|
||||||
|
else
|
||||||
assert_equal(collections_orig[key], collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})")
|
assert_equal(collections_orig[key], collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})")
|
||||||
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue