From 8eea37cbdbaca2c0eb94abca6c3c3e749f69e14c Mon Sep 17 00:00:00 2001
From: Raphael Sofaer <raphael@joindiaspora.com>
Date: Thu, 21 Jul 2011 13:41:46 -0700
Subject: [PATCH] Fix people socketing

---
 app/controllers/people_controller.rb      |  2 +-
 app/views/people/index.html.haml          | 12 ++++++------
 public/javascripts/web-socket-receiver.js |  8 +++++---
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index 912057be0e..2f2eeb3ff5 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -29,8 +29,8 @@ class PeopleController < ApplicationController
       format.all do
         #only do it if it is an email address
         if params[:q].try(:match, Devise.email_regexp)
-          webfinger(params[:q])
           people = Person.where(:diaspora_handle => params[:q])
+          webfinger(params[:q]) if people.empty?
         else
           people = Person.search(params[:q], current_user)
         end
diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml
index 63153be6e6..510c84d67b 100644
--- a/app/views/people/index.html.haml
+++ b/app/views/people/index.html.haml
@@ -20,16 +20,16 @@
         = params[:q]
 
 .span-15.append-1
-  - if @hashes.empty?
-    %p
-      =t('.no_one_found')
+  #people_stream.stream
+    - if @hashes.empty?
+      %p
+        =t('.no_one_found')
 
-  - else
-    #people_stream.stream
+    - else
       - for hash in @hashes
         = render :partial => 'people/person', :locals => hash
 
-    = will_paginate @people
+      = will_paginate @people
 
 .span-8.last
   %h4
diff --git a/public/javascripts/web-socket-receiver.js b/public/javascripts/web-socket-receiver.js
index eced351382..b00b30ae70 100644
--- a/public/javascripts/web-socket-receiver.js
+++ b/public/javascripts/web-socket-receiver.js
@@ -54,7 +54,7 @@ var WebSocketReceiver = {
           WebSocketReceiver.processLike(obj.post_id, obj.html);
 
         } else {
-          WebSocketReceiver.processPost(obj['class'], obj.post_id, obj.html, obj.aspect_ids);
+          WebSocketReceiver.processPost(obj.html, obj.aspect_ids);
         }
       }
   },
@@ -67,7 +67,9 @@ var WebSocketReceiver = {
       result_ul.siblings('.error').show();
       result_ul.find('.error').text(response.response).show();
     } else {
-      $('#people_stream').prepend(response.html).slideDown('slow', function(){});
+      stream = $('#people_stream');
+      stream.find('p').remove();
+      stream.prepend(response.html).slideDown('slow', function(){});
       var first_li = result_ul.find('li:first');
       first_li.hide();
       first_li.after(response.html);
@@ -131,7 +133,7 @@ var WebSocketReceiver = {
     $('.likes', "#" + targetGUID).first().html(html);
   },
 
-  processPost: function(className, postId, html, aspectIds) {
+  processPost: function(html, aspectIds) {
     if(WebSocketReceiver.onPageForAspects(aspectIds)) {
       ContentUpdater.addPostToStream(html);
     }
-- 
GitLab