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
action_hash[:photo_hash] = object.thumb_hash
end
if object.person.owner_id == uid
acton_hash[:mine?] == true
elsif object.is_a? StatusMessage
action_hash[:status_message_hash] = object.latest_hash
action_hash[:status_message_hash][:mine?] = true if object.person.owner_id == uid
end
action_hash.to_json

View file

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

View file

@ -12,8 +12,7 @@
//Attach onmessage to websocket
ws.onmessage = function(evt) {
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"){
processRetraction(obj['post_id']);
@ -23,11 +22,10 @@
}else if (obj['class']=='photos' && onPageForClass('albums')){
processPhotoInAlbum(obj['photo_hash'])
}else if (obj['class']=='status_messages'){
processStatusMessage(obj['class'], obj['html'], obj['status_message_hash'], obj['group_id'])
}else{
if( (obj['mine?'])|| (onPageForClass(obj['class']) || onPageForGroup(obj['group_id'])) ){
processPost(obj['class'], obj['html'])
}
processPost(obj['class'], obj['html'], obj['group_id'])
}
@ -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){
$("#latest_message").text(messageHash['text']);
$("#latest_message_time").text(' - just now');