DG IZ RS; deletion now gets sent through the websocket

This commit is contained in:
danielvincent 2010-07-02 15:16:28 -07:00
parent 8e6ddb4b2e
commit df3fe6c2a9
5 changed files with 24 additions and 9 deletions

View file

@ -23,7 +23,7 @@ class Post
after_save :notify_friends
before_destroy :propagate_retraction
after_destroy :destroy_comments
after_destroy :destroy_comments, :remove_from_view
def self.stream
Post.sort(:created_at.desc).all
@ -56,6 +56,9 @@ class Post
WebSocket.update_clients(self)
end
def remove_from_view
WebSocket.update_clients(Retraction.for(self))
end
end

View file

@ -15,4 +15,8 @@ class Retraction
attr_accessor :post_id
attr_accessor :person_id
def perform
Post.delete(self.post_id)
end
end

View file

@ -15,13 +15,19 @@
function onPageOne() {
var c = document.location.search.charAt(document.location.search.length-1);
return ((c =='') || (c== '1'))
return ((c =='') || (c== '1'));
}
if (obj['class']=="comments"){
if (obj['class']=="retractions"){
var post_id = obj['post_id'];
$('#' + post_id ).fadeOut(500, function(){
$(this).remove;
});
}else if (obj['class']=="comments"){
var post_id = obj['post_id']
$('#'+ obj['post_id'] + ' .comment_set li:last' ).before(
$('#'+ post_id + ' .comment_set li:last' ).before(
$(obj['html']).fadeIn("fast", function(){})
)
}else if(((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) && onPageOne()) {

View file

@ -32,7 +32,9 @@ module Diaspora
objects.each do |p|
if p.is_a? Retraction
Post.delete( p.post_id )
p.perform
#This line checks if the sender was in the database, among other things?
elsif p.respond_to?(:person) && !(p.person.nil?) #WTF
p.save

View file

@ -14,7 +14,7 @@ module SocketRenderer
def self.view_hash(object)
begin
v = view_for(object)
v = view_for(object) unless object.is_a? Retraction
rescue Exception => e
puts "in failzord " + v.inspect
@ -34,7 +34,7 @@ module SocketRenderer
if object.is_a? Post
object.id
else
object.post.id
object.post_id
end
end
end