Updated route matches in home_controller

Added in set_data_for_meta too
This commit is contained in:
mgabdev 2019-08-18 00:09:25 -04:00
parent 5750786d1a
commit d084b8d5f9

View File

@ -13,6 +13,8 @@ class HomeController < ApplicationController
private private
def set_data_for_meta def set_data_for_meta
return if find_route_matches
if params[:username].present? if params[:username].present?
@account = Account.find_local(params[:username]) @account = Account.find_local(params[:username])
elsif params[:account_username].present? elsif params[:account_username].present?
@ -35,13 +37,15 @@ class HomeController < ApplicationController
return if user_signed_in? return if user_signed_in?
# if no current user, dont allow to navigate to these paths # if no current user, dont allow to navigate to these paths
matches = request.path.match(/\A\/(home|groups|tags|lists|notifications|explore|follow_requests|blocks|domain_blocks|mutes)/) if find_route_matches
if matches
redirect_to(homepage_path) redirect_to(homepage_path)
end end
end end
def find_route_matches
request.path.match(/\A\/(home|groups|lists|notifications|explore|follow_requests|blocks|domain_blocks|mutes)/)
end
def set_initial_state_json def set_initial_state_json
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer) serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
@initial_state_json = serializable_resource.to_json @initial_state_json = serializable_resource.to_json