handle_rpc_json: do not crash if net-alert is somehow unavailable
This commit is contained in:
parent
b55aec078c
commit
df63125dd7
21
js/tt-rss.js
21
js/tt-rss.js
|
@ -989,6 +989,12 @@ function handle_rpc_json(transport, scheduled_call) {
|
||||||
try {
|
try {
|
||||||
var reply = JSON.parse(transport.responseText);
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
|
var netalert_dijit = dijit.byId("net-alert");
|
||||||
|
var netalert = false;
|
||||||
|
|
||||||
|
if (netalert_dijit)
|
||||||
|
netalert = netalert_dijit.domNode;
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
|
||||||
var error = reply['error'];
|
var error = reply['error'];
|
||||||
|
@ -1035,16 +1041,21 @@ function handle_rpc_json(transport, scheduled_call) {
|
||||||
if (runtime_info)
|
if (runtime_info)
|
||||||
parse_runtime_info(runtime_info);
|
parse_runtime_info(runtime_info);
|
||||||
|
|
||||||
Element.hide(dijit.byId("net-alert").domNode);
|
if (netalert) Element.hide(netalert);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//notify_error("Error communicating with server.");
|
if (netalert)
|
||||||
Element.show(dijit.byId("net-alert").domNode);
|
Element.show(netalert);
|
||||||
|
else
|
||||||
|
notify_error("Communication problem with server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Element.show(dijit.byId("net-alert").domNode);
|
if (netalert)
|
||||||
//notify_error("Error communicating with server.");
|
Element.show(netalert);
|
||||||
|
else
|
||||||
|
notify_error("Communication problem with server.");
|
||||||
|
|
||||||
console.log(e);
|
console.log(e);
|
||||||
//exception_error("handle_rpc_json", e, transport);
|
//exception_error("handle_rpc_json", e, transport);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,14 +194,11 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
|
||||||
else
|
else
|
||||||
request_counters(true);
|
request_counters(true);
|
||||||
|
|
||||||
} else if (transport.responseText) {
|
} else {
|
||||||
console.error("Invalid object received: " + transport.responseText);
|
console.error("Invalid object received: " + transport.responseText);
|
||||||
dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
|
dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
|
||||||
__('Could not update headlines (invalid object received - see error console for details)') +
|
__('Could not update headlines (invalid object received - see error console for details)') +
|
||||||
"</div>");
|
"</div>");
|
||||||
} else {
|
|
||||||
//notify_error("Error communicating with server.");
|
|
||||||
Element.show(dijit.byId("net-alert").domNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_infscroll_request_sent = 0;
|
_infscroll_request_sent = 0;
|
||||||
|
@ -318,13 +315,11 @@ function article_callback2(transport, id) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
} else if (transport.responseText) {
|
} else {
|
||||||
console.error("Invalid object received: " + transport.responseText);
|
console.error("Invalid object received: " + transport.responseText);
|
||||||
|
|
||||||
render_article("<div class='whiteBox'>" +
|
render_article("<div class='whiteBox'>" +
|
||||||
__('Could not display article (invalid object received - see error console for details)') + "</div>");
|
__('Could not display article (invalid object received - see error console for details)') + "</div>");
|
||||||
} else {
|
|
||||||
Element.show(dijit.byId("net-alert").domNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
|
var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
|
||||||
|
|
Loading…
Reference in New Issue