diff --git a/src/UI/UIWindow.js b/src/UI/UIWindow.js index 88ead0f4..a922e403 100644 --- a/src/UI/UIWindow.js +++ b/src/UI/UIWindow.js @@ -311,6 +311,8 @@ async function UIWindow(options) { // Add 'This folder is empty' message by default h += `
This folder is empty
`; + h += `
Error message is missing
`; + // Loading spinner h += `
`; h +=`circle anim`; diff --git a/src/css/style.css b/src/css/style.css index 64fb525d..8553d8fe 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -721,6 +721,14 @@ span.header-sort-icon img { display: none; } +.explorer-error-message { + text-align: center; + margin-top: 20px; + color: #935c5c; + -webkit-font-smoothing: antialiased; + display: none; +} + .explorer-loading-spinner { margin-top: 20px; font-size: 13px; diff --git a/src/helpers.js b/src/helpers.js index 5eeb2cbb..1b76ac9f 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1165,6 +1165,8 @@ window.refresh_item_container = function(el_item_container, options){ let el_window = $(el_item_container).closest('.window'); let el_window_head_icon = $(el_window).find('.window-head-icon'); const loading_spinner = $(el_item_container).find('.explorer-loading-spinner'); + const error_message = $(el_item_container).find('.explorer-error-message'); + const empty_message = $(el_item_container).find('.explorer-empty-message'); if(options.fadeInItems) $(el_item_container).css('opacity', '0') @@ -1177,6 +1179,9 @@ window.refresh_item_container = function(el_item_container, options){ // is already loaded. $(loading_spinner).hide(); + // Hide the error message in case it's visible + $(error_message).hide(); + // current timestamp in milliseconds let start_ts = new Date().getTime(); @@ -1369,6 +1374,19 @@ window.refresh_item_container = function(el_item_container, options){ // This makes sure the loading spinner shows up if the request takes longer than 1 second // and stay there for at least 1 second since the flickering is annoying (Date.now() - start_ts) > 1000 ? 1000 : 1) + }).catch(e => { + // clear loading timeout + clearTimeout(loading_timeout); + + // hide other messages/indicators + $(loading_spinner).hide(); + $(empty_message).hide(); + + // UIAlert('Failed to load directory' + (e && e.message ? ': ' + e.message : '')); + + // show error message + $(error_message).html('Failed to load directory' + (e && e.message ? ': ' + e.message : '')); + $(error_message).show(); }); }