From 9384e69dd428189edd8c97ebe396f463a1c00d2b Mon Sep 17 00:00:00 2001 From: jcass Date: Sun, 19 Feb 2017 19:42:40 +0200 Subject: [PATCH] Show offline message until page refresh is completed. --- mopidy_musicbox_webclient/static/js/gui.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mopidy_musicbox_webclient/static/js/gui.js b/mopidy_musicbox_webclient/static/js/gui.js index df0cbe5..d897f80 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -366,13 +366,6 @@ function updateStatusOfAll () { } function locationHashChanged () { - if (!mopidy) { - // Mopidy connection not yet established. User probably clicked 'Refresh' in their - // browser and the page is still loading. We can safely ignore this call as it will - // be invoked again later when the page has finished loading and $(document).ready() - // is triggered. - return false - } var hash = document.location.hash.split('?') // remove # var divid = hash[0].substr(1) @@ -404,12 +397,20 @@ function locationHashChanged () { break case 'artists': if (uri !== '') { - library.showArtist(uri, mopidy) + if (mopidy) { + library.showArtist(uri, mopidy) + } else { + showOffline(true) // Page refreshed - wait for mopidy object to be initialized. + } } break case 'albums': if (uri !== '') { - library.showAlbum(uri, mopidy) + if (mopidy) { + library.showAlbum(uri, mopidy) + } else { + showOffline(true) // Page refreshed - wait for mopidy object to be initialized. + } } break default: // Default footer