DG IZ; reverted to before removing latest message methods

This commit is contained in:
ilya 2010-08-17 17:40:48 -07:00
parent 054dafdf99
commit f15b3c46b2
3 changed files with 18 additions and 9 deletions

View file

@ -17,9 +17,9 @@ module SocketsHelper
if object.is_a? Photo if object.is_a? Photo
action_hash[:photo_hash] = object.thumb_hash action_hash[:photo_hash] = object.thumb_hash
end elsif object.is_a? StatusMessage
if object.person.owner_id == uid action_hash[:status_message_hash] = object.latest_hash
acton_hash[:mine?] == true action_hash[:status_message_hash][:mine?] = true if object.person.owner_id == uid
end end
action_hash.to_json action_hash.to_json

View file

@ -21,5 +21,8 @@ class StatusMessage < Post
XML XML
end end
def latest_hash
{ :text => message}
end
end end

View file

@ -12,8 +12,7 @@
//Attach onmessage to websocket //Attach onmessage to websocket
ws.onmessage = function(evt) { ws.onmessage = function(evt) {
var obj = jQuery.parseJSON(evt.data); var obj = jQuery.parseJSON(evt.data);
debug("got a " + obj['class'] ); debug("got a " + obj['class'] + " for group " + obj['group_id']);
if (obj['class']=="retractions"){ if (obj['class']=="retractions"){
processRetraction(obj['post_id']); processRetraction(obj['post_id']);
@ -23,11 +22,10 @@
}else if (obj['class']=='photos' && onPageForClass('albums')){ }else if (obj['class']=='photos' && onPageForClass('albums')){
processPhotoInAlbum(obj['photo_hash']) processPhotoInAlbum(obj['photo_hash'])
}else if (obj['class']=='status_messages'){
processStatusMessage(obj['class'], obj['html'], obj['status_message_hash'], obj['group_id'])
}else{ }else{
if( (obj['mine?'])|| (onPageForClass(obj['class']) || onPageForGroup(obj['group_id'])) ){ processPost(obj['class'], obj['html'], obj['group_id'])
processPost(obj['class'], obj['html'])
}
} }
@ -64,6 +62,14 @@
} }
} }
function processStatusMessage(className, html, messageHash, groupId){
processPost(className, html, groupId);
console.log(messageHash)
if(messageHash['mine?']){
updateMyLatestStatus(messageHash);
}
}
function updateMyLatestStatus(messageHash){ function updateMyLatestStatus(messageHash){
$("#latest_message").text(messageHash['text']); $("#latest_message").text(messageHash['text']);
$("#latest_message_time").text(' - just now'); $("#latest_message_time").text(' - just now');