diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2016-09-19 02:23:37 +0300 |
---|---|---|
committer | Steffen van Bergerem <svbergerem@omgsrsly.net> | 2016-09-28 22:59:08 +0300 |
commit | 459ebffa6ebaa30a01c2d7edc653764f8cf60e09 (patch) | |
tree | 0fa0b71085f5a885f9a452225babe480ca222600 /app/controllers | |
parent | b8c76a331759422b5f6f670842dabf6548f40700 (diff) |
Start background search with gon
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/people_controller.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 303423aa8..930ed0b7c 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -39,13 +39,10 @@ class PeopleController < ApplicationController end format.any(:html, :mobile) do - #only do it if it is an email address + # only do it if it is a diaspora*-ID if diaspora_id?(search_query) @people = Person.where(diaspora_handle: search_query.downcase, closed_account: false) - if @people.empty? - Workers::FetchWebfinger.perform_async(search_query) - @background_query = search_query.downcase - end + background_search(search_query) if @people.empty? end @people = @people.paginate(:page => params[:page], :per_page => 15) @hashes = hashes_for_people(@people, @aspects) @@ -167,6 +164,12 @@ class PeopleController < ApplicationController raise Diaspora::AccountClosed if @person.closed_account? end + def background_search(search_query) + Workers::FetchWebfinger.perform_async(search_query) + @background_query = search_query.downcase + gon.preloads[:background_query] = @background_query + end + def hashes_for_people(people, aspects) people.map {|person| { |