diff --git a/app/assets/javascripts/app/controllers/_channel/form.coffee b/app/assets/javascripts/app/controllers/_channel/form.coffee index bc4517345..73ffd4274 100644 --- a/app/assets/javascripts/app/controllers/_channel/form.coffee +++ b/app/assets/javascripts/app/controllers/_channel/form.coffee @@ -12,7 +12,7 @@ class App.ChannelForm extends App.Controller constructor: -> super @title 'Form' - @subscribeId = App.Setting.subscribe(@render, initFetch: true) + @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) render: => App.Setting.unsubscribe(@subscribeId) diff --git a/app/assets/javascripts/app/controllers/_settings/area.coffee b/app/assets/javascripts/app/controllers/_settings/area.coffee index d8bf7c90c..36a718730 100644 --- a/app/assets/javascripts/app/controllers/_settings/area.coffee +++ b/app/assets/javascripts/app/controllers/_settings/area.coffee @@ -5,20 +5,7 @@ class App.SettingsArea extends App.Controller # check authentication return if !@authenticate() - @load() - - load: -> - @startLoading() - @ajax( - id: "setting_area_#{@area}" - type: 'GET' - url: "#{@apiPath}/settings/area/#{@area}" - processData: true - success: (data, status, xhr) => - @stopLoading() - App.Collection.load( sessionStorage: false, type: 'Setting', data: data ) - @render() - ) + @subscribeId = App.Setting.subscribe(@render, initFetch: true, clear: false) render: => diff --git a/app/assets/javascripts/app/lib/app_post/collection.coffee b/app/assets/javascripts/app/lib/app_post/collection.coffee index bd9867e73..7c7fb635b 100644 --- a/app/assets/javascripts/app/lib/app_post/collection.coffee +++ b/app/assets/javascripts/app/lib/app_post/collection.coffee @@ -85,16 +85,23 @@ class _collectionSingleton extends Spine.Module return # load data from object + listToRefresh = [] for key, object of params.data if !params.refresh && appObject + @log 'debug', 'refrest try', params.type, key # check if new object is newer, just load newer objects if object.updated_at && appObject.exists(key) exists = appObject.find(key) if exists.updated_at if exists.updated_at < object.updated_at - appObject.refresh(object) + listToRefresh.push object + @log 'debug', 'refrest newser', params.type, key else - appObject.refresh(object) + listToRefresh.push object + @log 'debug', 'refrest try no updated_at', params.type, key else - appObject.refresh(object) + listToRefresh.push object + @log 'debug', 'refrest new', params.type, key + return if _.isEmpty(listToRefresh) + appObject.refresh(listToRefresh) diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index c91dc5c86..1dda13a5e 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -335,13 +335,16 @@ class App.Model extends Spine.Model # fetch init collection if param.initFetch is true + clear = true + if param.clear is true || param.clear is false + clear = param.clear if !@initFetchActive @one 'refresh', (collection) => @initFetchActive = true callback(collection) @fetchFull( -> - clear: true + clear: clear ) else callback(@all()) diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 5d0aa802f..a98b1faa0 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -6,14 +6,6 @@ class SettingsController < ApplicationController # GET /settings def index return if deny_if_not_role(Z_ROLENAME_ADMIN) - - # only serve requested items - if params[:area] - model_index_render_result( Setting.where(area: params[:area]) ) - return - end - - # serve all items model_index_render(Setting, params) end