Skip to content

Commit

Permalink
better handling of load list errors
Browse files Browse the repository at this point in the history
This patch replaces the loading wheel that stays in case of load list error
by an appropriate error message that can be clicked to reload the list.

Also, periodic polling of the server will reload the list if the error message
is displayed.
  • Loading branch information
niol committed Aug 11, 2015
1 parent 1b183dd commit 170c6e9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
8 changes: 6 additions & 2 deletions public/css/style.css
Expand Up @@ -637,7 +637,7 @@ input {
}


.stream-more, .mark-these-read {
.stream-more, .mark-these-read, .stream-error {
margin-top:20px;
margin-bottom:10px;
height:35px;
Expand All @@ -658,7 +658,11 @@ input {
.stream-more.loading span {
display:none;
}


.stream-error {
display:none;
}

#fullscreen-entry {
display:none;
}
Expand Down
29 changes: 18 additions & 11 deletions public/js/selfoss-base.js
Expand Up @@ -162,6 +162,7 @@ var selfoss = {
return;
}

$('.stream-error').css('display', 'block').hide();
$('#content').addClass('loading').html("");

selfoss.activeAjaxReq = $.ajax({
Expand All @@ -187,19 +188,23 @@ var selfoss = {
}
if(selfoss.filter.sourcesNav)
selfoss.refreshSources(data.sources);

// clean up
$('#content').removeClass('loading');
selfoss.activeAjaxReq = null;
},
error: function(jqXHR, textStatus, errorThrown) {
if (textStatus == "abort")
return;
else if (textStatus == "parsererror")
if (textStatus == "parsererror")
location.reload();
else if (errorThrown)
selfoss.showError('Load list error: '+
textStatus+' '+errorThrown);
else {
if (textStatus == "abort")
return;
else if (errorThrown)
selfoss.showError('Load list error: '+
textStatus+' '+errorThrown);
$('.stream-error').show();
}
},
complete: function(jqXHR, textStatus) {
// clean up
$('#content').removeClass('loading');
selfoss.activeAjaxReq = null;
}
});
},
Expand All @@ -222,7 +227,9 @@ var selfoss = {
url: stats_url,
type: 'GET',
success: function(data) {
if( data.unread>0 && $('.stream-empty').is(':visible') ) {
if( data.unread>0 &&
($('.stream-empty').is(':visible') ||
$('.stream-error').is(':visible')) ) {
selfoss.reloadList();
} else {
selfoss.refreshStats(data.all, data.unread, data.starred);
Expand Down
2 changes: 2 additions & 0 deletions public/js/selfoss-events-entries.js
Expand Up @@ -126,6 +126,8 @@ selfoss.events.entries = function(e) {

$('.mark-these-read').unbind('click').click(selfoss.markVisibleRead);

$('.stream-error').unbind('click').click(selfoss.reloadList);

// more
$('.stream-more').unbind('click').click(function () {
var streamMore = $(this);
Expand Down
1 change: 1 addition & 0 deletions public/lang/en.ini
Expand Up @@ -47,3 +47,4 @@ lang_login_username=username
lang_login_password=password
lang_no_title=no title
lang_error=an error occured
lang_streamerror=No items loaded, reload?
2 changes: 2 additions & 0 deletions templates/home.phtml
Expand Up @@ -150,6 +150,8 @@
<?PHP echo $this->content; ?>
</div>

<div class="stream-error"><?PHP echo trim(\F3::get('lang_streamerror')); ?></div>

<!-- fullscreen popup -->
<div id="fullscreen-entry"></div>

Expand Down

0 comments on commit 170c6e9

Please sign in to comment.