RS; posted statuses now use the websocket to update latest, time is now styled right

This commit is contained in:
Raphael 2010-08-02 11:13:21 -07:00
parent b8ae6b44a2
commit d503c6541f
6 changed files with 29 additions and 9 deletions

View file

@ -22,6 +22,8 @@ module SocketsHelper
if object.is_a? Photo
action_hash[:photo_hash] = object.thumb_hash
elsif object.is_a? StatusMessage
action_hash[:status_message_hash] = object.latest_hash
end
action_hash.to_json

View file

@ -21,9 +21,8 @@ class StatusMessage < Post
XML
end
def ==(other)
(self.message == other.message) && (self.person.email == other.person.email)
def latest_hash
{:mine? => self.person == User.owner, :text => message}
end
end

View file

@ -20,9 +20,13 @@
}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'])
}else{
processPost(obj['class'], obj['html'])
}
};
ws.onclose = function() { debug("socket closed"); };
ws.onopen = function() {
@ -56,6 +60,18 @@
}
}
function processStatusMessage(className, html, messageHash){
processPost(className, html);
if(messageHash['mine?']){
updateMyLatestStatus(messageHash);
}
}
function updateMyLatestStatus(messageHash){
$("#latest_message").text(messageHash['text']);
$("#latest_message_time").text(' - just now');
}
function processPhotoInAlbum(photoHash){
if (location.href.indexOf(photoHash['album_id']) == -1){
return ;
@ -65,7 +81,7 @@
<img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" /> \
</a> </div>"
$("#thumbnails").append( $(html) )
$(".image_thumb img").load( function() {
$("#"+ photoHash['id'] + " img").load( function() {
$(this).fadeIn("slow");
});
}

View file

@ -51,7 +51,7 @@
%span#latest_message
= my_latest_message
- unless @latest_status_message.nil?
%span{:style => "font-size: small"}
%span{:style => "font-size: small", :id => 'latest_message_time'}
= " - #{how_long_ago @latest_status_message}"
%ul.nav

View file

@ -7,8 +7,6 @@
$("#new_status_message").submit(function() {
var new_status = $('#status_message_message').val() + " - just now";
$('#latest_message').text( new_status );
});
function selectPublisherTab(evt){

View file

@ -177,6 +177,11 @@ form {
#user_name #latest_message span {
size: small;
font-style: italic; }
#user_name #latest_message_time{
font-weight: normal;
color: #999999;
size: small;
font-style: italic; }
#user_name ul {
display: inline;
margin: 0;