DG IZ RS; deletion now gets sent through the websocket
This commit is contained in:
parent
8e6ddb4b2e
commit
df3fe6c2a9
5 changed files with 24 additions and 9 deletions
|
|
@ -23,7 +23,7 @@ class Post
|
||||||
after_save :notify_friends
|
after_save :notify_friends
|
||||||
|
|
||||||
before_destroy :propagate_retraction
|
before_destroy :propagate_retraction
|
||||||
after_destroy :destroy_comments
|
after_destroy :destroy_comments, :remove_from_view
|
||||||
|
|
||||||
def self.stream
|
def self.stream
|
||||||
Post.sort(:created_at.desc).all
|
Post.sort(:created_at.desc).all
|
||||||
|
|
@ -53,9 +53,12 @@ class Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_to_view
|
def send_to_view
|
||||||
WebSocket.update_clients(self)
|
WebSocket.update_clients(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_from_view
|
||||||
|
WebSocket.update_clients(Retraction.for(self))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,8 @@ class Retraction
|
||||||
attr_accessor :post_id
|
attr_accessor :post_id
|
||||||
attr_accessor :person_id
|
attr_accessor :person_id
|
||||||
|
|
||||||
|
def perform
|
||||||
|
Post.delete(self.post_id)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,19 @@
|
||||||
|
|
||||||
function onPageOne() {
|
function onPageOne() {
|
||||||
var c = document.location.search.charAt(document.location.search.length-1);
|
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']
|
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(){})
|
$(obj['html']).fadeIn("fast", function(){})
|
||||||
)
|
)
|
||||||
}else if(((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) && onPageOne()) {
|
}else if(((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) && onPageOne()) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,9 @@ module Diaspora
|
||||||
|
|
||||||
objects.each do |p|
|
objects.each do |p|
|
||||||
if p.is_a? Retraction
|
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?
|
#This line checks if the sender was in the database, among other things?
|
||||||
elsif p.respond_to?(:person) && !(p.person.nil?) #WTF
|
elsif p.respond_to?(:person) && !(p.person.nil?) #WTF
|
||||||
p.save
|
p.save
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ module SocketRenderer
|
||||||
|
|
||||||
def self.view_hash(object)
|
def self.view_hash(object)
|
||||||
begin
|
begin
|
||||||
v = view_for(object)
|
v = view_for(object) unless object.is_a? Retraction
|
||||||
|
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "in failzord " + v.inspect
|
puts "in failzord " + v.inspect
|
||||||
|
|
@ -34,7 +34,7 @@ module SocketRenderer
|
||||||
if object.is_a? Post
|
if object.is_a? Post
|
||||||
object.id
|
object.id
|
||||||
else
|
else
|
||||||
object.post.id
|
object.post_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue