Put preloads into gon.preloads
Fixed tagFollowing not getting into preloads
This commit is contained in:
parent
fb9b3e35c3
commit
aa472b25de
9 changed files with 25 additions and 18 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Refactor
|
||||
* Background actual mailing when sending invitations [#4069](https://github.com/diaspora/diaspora/issues/4069)
|
||||
* Set the current user on the client side through gon [#4028](https://github.com/diaspora/diaspora/issues/4028)
|
||||
|
||||
## Bug fixes
|
||||
* Don't focus comment form on 'show n more comments' [#4265](https://github.com/diaspora/diaspora/issues/4265)
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ var app = {
|
|||
initialize: function() {
|
||||
app.router = new app.Router();
|
||||
|
||||
var currentUser = false;
|
||||
if (window.preloads != undefined) {
|
||||
currentUser = app.user(window.preloads.user)
|
||||
if (window.gon == undefined) {
|
||||
window.gon = {preloads:{}};
|
||||
}
|
||||
app.currentUser = currentUser || new app.models.User();
|
||||
|
||||
app.currentUser = app.user(window.gon.user) || new app.models.User();
|
||||
|
||||
if(app.currentUser.authenticated()){
|
||||
app.header = new app.views.Header();
|
||||
|
|
@ -63,19 +63,19 @@ var app = {
|
|||
},
|
||||
|
||||
hasPreload : function(prop) {
|
||||
return !!(window.preloads && window.preloads[prop]) //returning boolean variable so that parsePreloads, which cleans up properly is used instead
|
||||
return !!(window.gon.preloads && window.gon.preloads[prop]) //returning boolean variable so that parsePreloads, which cleans up properly is used instead
|
||||
},
|
||||
|
||||
setPreload : function(prop, val) {
|
||||
window.preloads = window.preloads || {}
|
||||
window.preloads[prop] = val
|
||||
window.gon.preloads = window.gon.preloads || {}
|
||||
window.gon.preloads[prop] = val
|
||||
},
|
||||
|
||||
parsePreload : function(prop){
|
||||
if(!app.hasPreload(prop)) { return }
|
||||
|
||||
var preload = window.preloads[prop]
|
||||
delete window.preloads[prop] //prevent dirty state across navigates
|
||||
var preload = window.gon.preloads[prop]
|
||||
delete window.gon.preloads[prop] //prevent dirty state across navigates
|
||||
|
||||
return(preload)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ app.Router = Backbone.Router.extend({
|
|||
post.fetch({url : window.location})
|
||||
|
||||
function setPreloadAttributesAndNavigate(){
|
||||
window.preloads.post = post.attributes
|
||||
window.gon.preloads.post = post.attributes
|
||||
app.router.navigate(post.url(), {trigger:true, replace: true})
|
||||
}
|
||||
},
|
||||
|
|
@ -73,7 +73,7 @@ app.Router = Backbone.Router.extend({
|
|||
$("#tags_list").replaceWith(followedTagsView.render().el);
|
||||
followedTagsView.setupAutoSuggest();
|
||||
|
||||
app.tagFollowings.reset(preloads.tagFollowings);
|
||||
app.tagFollowings.reset(gon.preloads.tagFollowings);
|
||||
|
||||
if(name) {
|
||||
var followedTagsAction = new app.views.TagFollowingAction(
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ $(document).ready(function(){
|
|||
|
||||
function createUploader(){
|
||||
|
||||
var aspectIds = gon.aspect_ids;
|
||||
var aspectIds = gon.preloads.aspect_ids;
|
||||
|
||||
var uploader = new qq.FileUploaderBasic({
|
||||
element: document.getElementById('file-upload-publisher'),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ class ApplicationController < ActionController::Base
|
|||
before_filter :set_diaspora_header
|
||||
before_filter :set_grammatical_gender
|
||||
before_filter :mobile_switch
|
||||
before_filter :set_current_user_in_javascript
|
||||
before_filter :gon_set_current_user
|
||||
before_filter :gon_set_preloads
|
||||
|
||||
inflection_method :grammatical_gender => :gender
|
||||
|
||||
|
|
@ -138,11 +139,16 @@ class ApplicationController < ActionController::Base
|
|||
current_user.getting_started? ? getting_started_path : stream_path
|
||||
end
|
||||
|
||||
def set_current_user_in_javascript
|
||||
def gon_set_current_user
|
||||
return unless user_signed_in?
|
||||
a_ids = session[:a_ids] || []
|
||||
user = UserPresenter.new(current_user, a_ids)
|
||||
gon.push({:user => user})
|
||||
end
|
||||
|
||||
def gon_set_preloads
|
||||
return unless gon.preloads.nil?
|
||||
gon.preloads = {}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class StreamsController < ApplicationController
|
|||
end
|
||||
|
||||
def followed_tags
|
||||
gon.tagFollowings = tags
|
||||
gon.preloads[:tagFollowings] = tags
|
||||
stream_responder(Stream::FollowedTag)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TagsController < ApplicationController
|
|||
redirect_to(:action => :show, :name => downcased_tag_name) && return if tag_has_capitals?
|
||||
|
||||
if user_signed_in?
|
||||
gon.tagFollowings = tags
|
||||
gon.preloads[:tagFollowings] = tags
|
||||
end
|
||||
@stream = Stream::Tag.new(current_user, params[:name], :max_time => max_time, :page => params[:page])
|
||||
respond_with do |format|
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
%link{:rel => 'alternate', :type => "application/json+oembed", :href => "#{oembed_url(:url => post_url(@post))}"}
|
||||
= og_page_specific_tags(@post)
|
||||
|
||||
= include_gon(:camel_case => true, :namespace => :preloads)
|
||||
= include_gon(:camel_case => true)
|
||||
|
||||
%body
|
||||
= flash_messages
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ describe("app.views.Post.SmallFrame", function(){
|
|||
beforeEach(function(){
|
||||
app.page = { editMode : false }
|
||||
app.router = new app.Router()
|
||||
window.preloads = {}
|
||||
window.gon.preloads = {}
|
||||
spyOn(app.router, "navigate")
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue