Send assets and ticket list in one message.

This commit is contained in:
Martin Edenhofer 2016-09-28 00:05:46 +02:00
parent 5934207f82
commit a83d0bc819
2 changed files with 12 additions and 11 deletions

View file

@ -6,6 +6,9 @@ class _Singleton
@counter = 0 @counter = 0
App.Event.bind 'ticket_overview_list', (data) => App.Event.bind 'ticket_overview_list', (data) =>
if data.assets
App.Collection.loadAssets(data.assets)
delete data.assets
if !@overview[data.overview.view] if !@overview[data.overview.view]
@overview[data.overview.view] = {} @overview[data.overview.view] = {}
@overview[data.overview.view] = data @overview[data.overview.view] = data
@ -54,6 +57,7 @@ class _Singleton
@fetchActive[view] = false @fetchActive[view] = false
if data.assets if data.assets
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)
delete data.assets
@overview[data.index.overview.view] = data.index @overview[data.index.overview.view] = data.index
@callback(view, data.index) @callback(view, data.index)
error: => error: =>

View file

@ -89,27 +89,28 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
# push overviews # push overviews
results = [] results = []
index_and_lists.each { |index| index_and_lists.each { |data|
# do not deliver unchanged lists # do not deliver unchanged lists
next if @last_overview[index[:overview][:id]] == index next if @last_overview[data[:overview][:id]] == data
@last_overview[index[:overview][:id]] = index @last_overview[data[:overview][:id]] = data
assets = {} assets = {}
overview = Overview.lookup(id: index[:overview][:id]) overview = Overview.lookup(id: data[:overview][:id])
if asset_needed?(overview) if asset_needed?(overview)
assets = overview.assets(assets) assets = overview.assets(assets)
end end
index[:tickets].each { |ticket_meta| data[:tickets].each { |ticket_meta|
ticket = Ticket.lookup(id: ticket_meta[:id]) ticket = Ticket.lookup(id: ticket_meta[:id])
next if !asset_needed?(ticket) next if !asset_needed?(ticket)
assets = ticket.assets(assets) assets = ticket.assets(assets)
} }
data[:assets] = assets
if !@client if !@client
result = { result = {
event: 'ticket_overview_list', event: 'ticket_overview_list',
data: index, data: data,
} }
results.push result results.push result
else else
@ -117,13 +118,9 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
@client.log "push overview_list #{overview.link} for user #{@user.id}" @client.log "push overview_list #{overview.link} for user #{@user.id}"
# send update to browser # send update to browser
@client.send(
event: 'loadAssets',
data: assets,
)
@client.send( @client.send(
event: 'ticket_overview_list', event: 'ticket_overview_list',
data: index, data: data,
) )
end end
} }