RS; posted statuses now use the websocket to update latest, time is now styled right
This commit is contained in:
parent
b8ae6b44a2
commit
d503c6541f
6 changed files with 29 additions and 9 deletions
|
|
@ -22,6 +22,8 @@ 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
|
||||||
|
elsif object.is_a? StatusMessage
|
||||||
|
action_hash[:status_message_hash] = object.latest_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
action_hash.to_json
|
action_hash.to_json
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,8 @@ class StatusMessage < Post
|
||||||
XML
|
XML
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
def latest_hash
|
||||||
(self.message == other.message) && (self.person.email == other.person.email)
|
{:mine? => self.person == User.owner, :text => message}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,13 @@
|
||||||
|
|
||||||
}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'])
|
||||||
}else{
|
}else{
|
||||||
processPost(obj['class'], obj['html'])
|
processPost(obj['class'], obj['html'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
ws.onclose = function() { debug("socket closed"); };
|
ws.onclose = function() { debug("socket closed"); };
|
||||||
ws.onopen = function() {
|
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){
|
function processPhotoInAlbum(photoHash){
|
||||||
if (location.href.indexOf(photoHash['album_id']) == -1){
|
if (location.href.indexOf(photoHash['album_id']) == -1){
|
||||||
return ;
|
return ;
|
||||||
|
|
@ -65,7 +81,7 @@
|
||||||
<img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" /> \
|
<img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" /> \
|
||||||
</a> </div>"
|
</a> </div>"
|
||||||
$("#thumbnails").append( $(html) )
|
$("#thumbnails").append( $(html) )
|
||||||
$(".image_thumb img").load( function() {
|
$("#"+ photoHash['id'] + " img").load( function() {
|
||||||
$(this).fadeIn("slow");
|
$(this).fadeIn("slow");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
%span#latest_message
|
%span#latest_message
|
||||||
= my_latest_message
|
= my_latest_message
|
||||||
- unless @latest_status_message.nil?
|
- 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}"
|
= " - #{how_long_ago @latest_status_message}"
|
||||||
|
|
||||||
%ul.nav
|
%ul.nav
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
$("#new_status_message").submit(function() {
|
$("#new_status_message").submit(function() {
|
||||||
|
|
||||||
var new_status = $('#status_message_message').val() + " - just now";
|
|
||||||
$('#latest_message').text( new_status );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function selectPublisherTab(evt){
|
function selectPublisherTab(evt){
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,11 @@ form {
|
||||||
#user_name #latest_message span {
|
#user_name #latest_message span {
|
||||||
size: small;
|
size: small;
|
||||||
font-style: italic; }
|
font-style: italic; }
|
||||||
|
#user_name #latest_message_time{
|
||||||
|
font-weight: normal;
|
||||||
|
color: #999999;
|
||||||
|
size: small;
|
||||||
|
font-style: italic; }
|
||||||
#user_name ul {
|
#user_name ul {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue