Send assets and ticket list in one message.
This commit is contained in:
parent
5934207f82
commit
a83d0bc819
2 changed files with 12 additions and 11 deletions
|
@ -6,6 +6,9 @@ class _Singleton
|
|||
@counter = 0
|
||||
|
||||
App.Event.bind 'ticket_overview_list', (data) =>
|
||||
if data.assets
|
||||
App.Collection.loadAssets(data.assets)
|
||||
delete data.assets
|
||||
if !@overview[data.overview.view]
|
||||
@overview[data.overview.view] = {}
|
||||
@overview[data.overview.view] = data
|
||||
|
@ -54,6 +57,7 @@ class _Singleton
|
|||
@fetchActive[view] = false
|
||||
if data.assets
|
||||
App.Collection.loadAssets(data.assets)
|
||||
delete data.assets
|
||||
@overview[data.index.overview.view] = data.index
|
||||
@callback(view, data.index)
|
||||
error: =>
|
||||
|
|
|
@ -89,27 +89,28 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
|
|||
|
||||
# push overviews
|
||||
results = []
|
||||
index_and_lists.each { |index|
|
||||
index_and_lists.each { |data|
|
||||
|
||||
# do not deliver unchanged lists
|
||||
next if @last_overview[index[:overview][:id]] == index
|
||||
@last_overview[index[:overview][:id]] = index
|
||||
next if @last_overview[data[:overview][:id]] == data
|
||||
@last_overview[data[:overview][:id]] = data
|
||||
|
||||
assets = {}
|
||||
overview = Overview.lookup(id: index[:overview][:id])
|
||||
overview = Overview.lookup(id: data[:overview][:id])
|
||||
if asset_needed?(overview)
|
||||
assets = overview.assets(assets)
|
||||
end
|
||||
index[:tickets].each { |ticket_meta|
|
||||
data[:tickets].each { |ticket_meta|
|
||||
ticket = Ticket.lookup(id: ticket_meta[:id])
|
||||
next if !asset_needed?(ticket)
|
||||
assets = ticket.assets(assets)
|
||||
}
|
||||
data[:assets] = assets
|
||||
|
||||
if !@client
|
||||
result = {
|
||||
event: 'ticket_overview_list',
|
||||
data: index,
|
||||
data: data,
|
||||
}
|
||||
results.push result
|
||||
else
|
||||
|
@ -117,13 +118,9 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
|
|||
@client.log "push overview_list #{overview.link} for user #{@user.id}"
|
||||
|
||||
# send update to browser
|
||||
@client.send(
|
||||
event: 'loadAssets',
|
||||
data: assets,
|
||||
)
|
||||
@client.send(
|
||||
event: 'ticket_overview_list',
|
||||
data: index,
|
||||
data: data,
|
||||
)
|
||||
end
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue