Fall back to using track Ref if playlist lookup fails.

Fixes #226.
This commit is contained in:
jcass 2017-02-04 18:27:34 +02:00
parent 01ae68ebc6
commit 25a2d09601
4 changed files with 8 additions and 5 deletions

View File

@ -123,6 +123,7 @@ v2.4.0 (UNRELEASED)
- Now initializes the GUI properly, even if the user is offline or the Mopidy server cannot be reached. - Now initializes the GUI properly, even if the user is offline or the Mopidy server cannot be reached.
- Fixed `Alarm Clock <https://pypi.python.org/pypi/Mopidy-AlarmClock/>`_ detection. - Fixed `Alarm Clock <https://pypi.python.org/pypi/Mopidy-AlarmClock/>`_ detection.
- When browsing the library using the local 'File' extension, only playable audio files will have context menu icons. - When browsing the library using the local 'File' extension, only playable audio files will have context menu icons.
- Playlists will now list tracks even if they are no longer available in the library. (Fixes: `#226 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/226>`_).
v2.3.0 (2016-05-15) v2.3.0 (2016-05-15)
------------------- -------------------

View File

@ -479,9 +479,9 @@ function showOffline (on) {
} }
// from http://dzone.com/snippets/validate-url-regexp // from http://dzone.com/snippets/validate-url-regexp
function validUri (str) { function validUri (uri) {
var regexp = /^(mms|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ var regexp = /^(mms|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
return regexp.test(str) return regexp.test(uri)
} }
function validServiceUri (str) { function validServiceUri (str) {
@ -494,7 +494,7 @@ function getScheme (uri) {
function isPlayable (track) { function isPlayable (track) {
if (typeof track.type === 'undefined' || track.type === 'track') { if (typeof track.type === 'undefined' || track.type === 'track') {
if (getScheme(track.uri) === 'file') { if (track.uri && getScheme(track.uri) === 'file') {
var ext = track.uri.split('.').pop().toLowerCase() var ext = track.uri.split('.').pop().toLowerCase()
if ($.inArray(ext, audioExt) === -1) { if ($.inArray(ext, audioExt) === -1) {
// Files must have the correct extension // Files must have the correct extension

View File

@ -187,9 +187,11 @@ function processPlaylistItems (resultDict) {
return mopidy.library.lookup({'uris': trackUris}).then(function (tracks) { return mopidy.library.lookup({'uris': trackUris}).then(function (tracks) {
// Transform from dict to list and cache result // Transform from dict to list and cache result
var newplaylisturi = resultDict.uri var newplaylisturi = resultDict.uri
var track
playlists[newplaylisturi] = {'uri': newplaylisturi, 'tracks': []} playlists[newplaylisturi] = {'uri': newplaylisturi, 'tracks': []}
for (i = 0; i < trackUris.length; i++) { for (i = 0; i < trackUris.length; i++) {
playlists[newplaylisturi].tracks.push(tracks[trackUris[i]][0]) track = tracks[trackUris[i]][0] || resultDict.items[i] // Fall back to using track Ref if lookup failed.
playlists[newplaylisturi].tracks.push(track)
} }
showLoading(false) showLoading(false)
return playlists[newplaylisturi].tracks return playlists[newplaylisturi].tracks

View File

@ -1,6 +1,6 @@
CACHE MANIFEST CACHE MANIFEST
# 2017-01-18:v2 # 2017-02-04:v1
NETWORK: NETWORK:
* *