Improved way how to load/reset collections.
This commit is contained in:
parent
2032847179
commit
f99c72907c
4 changed files with 14 additions and 13 deletions
|
@ -84,9 +84,10 @@ class App.Auth
|
|||
App.Session.set( key, value )
|
||||
|
||||
# refresh default collections
|
||||
for key, value of data.default_collections
|
||||
App[key].refresh( value, options: { clear: true } )
|
||||
if data.collections
|
||||
App.Event.trigger 'resetCollection', data.collections
|
||||
|
||||
# trigger auth ok with new session data
|
||||
App.Event.trigger( 'auth', data.session )
|
||||
|
||||
# init of i18n
|
||||
|
|
|
@ -31,13 +31,14 @@ class _collectionSingleton extends Spine.Module
|
|||
|
||||
# add trigger - bind new events
|
||||
App.Event.bind 'resetCollection', (data) =>
|
||||
if !data
|
||||
@log 'error', 'resetCollection:trigger, got no data, cant for collections'
|
||||
return
|
||||
|
||||
# load collections
|
||||
if data.collections
|
||||
for type of data.collections
|
||||
|
||||
@log 'debug', 'resetCollection:trigger', type, data.collections[type]
|
||||
@reset( localStorage: data.localStorage, type: type, data: data.collections[type] )
|
||||
for type, collection of data
|
||||
@log 'debug', 'resetCollection:trigger', type, collection
|
||||
@reset( localStorage: data.localStorage, type: type, data: collection )
|
||||
|
||||
# find collections to load
|
||||
@_loadObjectsFromLocalStore()
|
||||
|
|
|
@ -31,7 +31,7 @@ class SessionsController < ApplicationController
|
|||
user.activity_stream_log( 'session started', user.id, true )
|
||||
|
||||
# auto population of default collections
|
||||
default_collection = SessionHelper::default_collections(user)
|
||||
collections = SessionHelper::default_collections(user)
|
||||
|
||||
# set session user_id
|
||||
user = User.find_fulldata(user.id)
|
||||
|
@ -50,9 +50,9 @@ class SessionsController < ApplicationController
|
|||
|
||||
# return new session data
|
||||
render :json => {
|
||||
:session => user,
|
||||
:default_collections => default_collection,
|
||||
:logon_session => logon_session_key,
|
||||
:session => user,
|
||||
:collections => collections,
|
||||
:logon_session => logon_session_key,
|
||||
},
|
||||
:status => :created
|
||||
end
|
||||
|
|
|
@ -56,8 +56,7 @@ module Sessions::Backend::Collections
|
|||
|
||||
# send update to browser
|
||||
data = {}
|
||||
data['collections'] = {}
|
||||
data['collections'][key] = push_collections
|
||||
data[key] = push_collections
|
||||
client.send({
|
||||
:event => 'resetCollection',
|
||||
:data => data,
|
||||
|
|
Loading…
Reference in a new issue