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
1 changed files with 7 additions and 3 deletions

View File

@ -13,6 +13,8 @@ class HomeController < ApplicationController
private
def set_data_for_meta
return if find_route_matches
if params[:username].present?
@account = Account.find_local(params[:username])
elsif params[:account_username].present?
@ -35,13 +37,15 @@ class HomeController < ApplicationController
return if user_signed_in?
# 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 matches
if find_route_matches
redirect_to(homepage_path)
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
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
@initial_state_json = serializable_resource.to_json