Make websocket closed message less disruptive
This commit is contained in:
parent
cb483beada
commit
94bc18e467
2 changed files with 14 additions and 15 deletions
|
|
@ -35,6 +35,4 @@ en:
|
|||
infinite_scroll:
|
||||
no_more: "No more posts."
|
||||
web_sockets:
|
||||
disconnected:
|
||||
title: "You have been disconnected."
|
||||
body: "Posts will no longer be streamed live."
|
||||
disconnected: "The websocket is closed; posts will no longer be streamed live."
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ var WebSocketReceiver = {
|
|||
//Attach onmessage to websocket
|
||||
ws.onmessage = WSR.onMessage;
|
||||
ws.onclose = function() {
|
||||
Diaspora.widgets.alert.alert(
|
||||
Diaspora.widgets.i18n.t("web_sockets.disconnected.title"),
|
||||
Diaspora.widgets.i18n.t("web_sockets.disconnected.body")
|
||||
);
|
||||
|
||||
Diaspora.widgets.notifications.showNotification({
|
||||
html: '<div class="notification">' +
|
||||
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
|
||||
'</div>'
|
||||
});
|
||||
|
||||
WSR.debug("socket closed");
|
||||
};
|
||||
ws.onopen = function() {
|
||||
|
|
@ -42,7 +43,7 @@ var WebSocketReceiver = {
|
|||
});
|
||||
|
||||
} else if (obj['class']=="likes") {
|
||||
WebSocketReceiver.processLike(obj.post_id, obj.html)
|
||||
WebSocketReceiver.processLike(obj.post_id, obj.html);
|
||||
|
||||
} else {
|
||||
WebSocketReceiver.processPost(obj['class'], obj.post_id, obj.html, obj.aspect_ids);
|
||||
|
|
@ -60,7 +61,7 @@ var WebSocketReceiver = {
|
|||
} else {
|
||||
$('#people_stream').prepend(response.html).slideDown('slow', function(){});
|
||||
var first_li = result_ul.find('li:first');
|
||||
first_li.hide()
|
||||
first_li.hide();
|
||||
first_li.after(response.html);
|
||||
result_ul.find("[name='request[into]']").val(result_ul.attr('aspect_id'));
|
||||
result_ul.children(':nth-child(2)').slideDown('fast', function(){});
|
||||
|
|
@ -76,14 +77,14 @@ var WebSocketReceiver = {
|
|||
$("*[data-guid='" + post_id + "']").fadeOut(400, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
if($("#main_stream")[0].childElementCount == 0) {
|
||||
if($("#main_stream")[0].childElementCount === 0) {
|
||||
$("#no_posts").fadeIn(200);
|
||||
}
|
||||
},
|
||||
|
||||
processComment: function(postId, commentId, html, opts) {
|
||||
|
||||
if( $(".comment[data-guid='"+commentId+"']").length == 0 ) {
|
||||
if( $(".comment[data-guid='"+commentId+"']").length === 0 ) {
|
||||
|
||||
var post = $("*[data-guid='"+postId+"']'"),
|
||||
prevComments = $('.comment.posted', post);
|
||||
|
|
@ -131,7 +132,7 @@ var WebSocketReceiver = {
|
|||
},
|
||||
|
||||
addPostToStream: function(postId, html) {
|
||||
if( $(".stream_element[data-guid='" + postId + "']").length == 0 ) {
|
||||
if( $(".stream_element[data-guid='" + postId + "']").length === 0 ) {
|
||||
var streamElement = $(html);
|
||||
|
||||
var showMessage = function() {
|
||||
|
|
@ -164,7 +165,7 @@ var WebSocketReceiver = {
|
|||
if(WebSocketReceiver.onStreamForAspect(value, streamIds)) {
|
||||
found = true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
});
|
||||
return found;
|
||||
},
|
||||
|
|
@ -175,7 +176,7 @@ var WebSocketReceiver = {
|
|||
|
||||
onPageOne: function() {
|
||||
var c = document.location.search.charAt(document.location.search.length-1);
|
||||
return ((c =='') || (c== '1'));
|
||||
return ((c === '') || (c === '1'));
|
||||
},
|
||||
debug: function(str) {
|
||||
$("#debug").append("<p>" + str);
|
||||
|
|
|
|||
Loading…
Reference in a new issue