Skip to content

Commit

Permalink
Use 'm3u' format for saving playlists. Invalidate the playlist cache …
Browse files Browse the repository at this point in the history
…on refresh or external changes.

Fixes pimusicbox#173. Fixes 177.
  • Loading branch information
jcass77 committed Feb 28, 2016
1 parent f7ea11d commit 2777875
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ v2.2.0 (UNRELEASED)
- Volume slider now works with Mopidy-ALSAMixer again. (Fixes: `#168 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/168>`_).
- Now falls back to track artist if album artist is not available for rendering cover art. (Fixes: `#128 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/128>`_).
- Replace Javascript prompt with jQuery Mobile equivalent. (Fixes: `#113 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/113>`_).
- Fix playlist refresh button. (Fixes: `#173 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/173>`_).
- Update save queue functionality to use 'm3u' format. (Fixes: `#177 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/177>`_).

v2.1.1 (2016-02-04)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion mopidy_musicbox_webclient/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ <h2>Artists</h2>
<button class="btn" type="button" id="overwriteConfirmBtn">
Ok
</button>
<button class="btn" type="button" onclick="return $('#popupOverwrite').popup('close');">
<button class="btn" type="button" onclick="$('#popupOverwrite').popup('close'); return $('#popupSave').popup('open');">
Cancel
</button>
</div>
Expand Down
28 changes: 12 additions & 16 deletions mopidy_musicbox_webclient/static/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,8 @@ function removeTrack() {
}

function clearQueue() {
mopidy.playback.stop().then(
mopidy.tracklist.clear().then(
resetSong()
)
mopidy.tracklist.clear().then(
resetSong()
);
return false;
}
Expand All @@ -235,21 +233,17 @@ function showSavePopup(){

function saveQueue() {
mopidy.tracklist.getTracks().then(function(tracks) {
var plname = $('#saveinput').val().trim();
if (plname != null && plname != "") {
mopidy.playlists.filter({"name": plname}).then(function(existing) {
var exists = false;
for (var i = 0; i < existing.length; i++) {
exists = exists || existing[i].uri.indexOf("m3u:") == 0 || existing[i].uri.indexOf("local:") == 0;
}
var playlistName = $('#saveinput').val().trim();
if (playlistName != null && playlistName != "") {
getPlaylistByName(playlistName, 'm3u', false).then(function(exists) {
if (exists) {
$('#popupSave').popup('close');
$('#popupOverwrite').popup('open');
$('#overwriteConfirmBtn').click(function() {
initSave(plname, tracks);
initSave(playlistName, tracks);
});
} else {
initSave(plname, tracks);
initSave(playlistName, tracks);
}
});
}
Expand All @@ -262,15 +256,17 @@ function initSave(playlistName, tracks) {
$('#popupSave').popup('close');
$('#saveinput').val('');
toast('Saving...');
mopidy.playlists.create({'name': playlistName, 'uri_scheme': "local"}).then(function(playlist) {
mopidy.playlists.create({'name': playlistName, 'uri_scheme': "m3u"}).then(function(playlist) {
playlist.tracks = tracks;
mopidy.playlists.save({'playlist': playlist}).then();
getPlaylists();
});
}

function refreshPlaylists() {
mopidy.playlists.refresh();
mopidy.playlists.refresh().then(function() {
playlists = {};
$('#playlisttracksdiv').hide();
});
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions mopidy_musicbox_webclient/static/js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ function initSocketevents() {
getPlaylists();
});

mopidy.on("event:playlistChanged", function(data) {
$('#playlisttracksdiv').hide();
delete playlists[data["playlist"].uri];

This comment has been minimized.

Copy link
@kingosticks

kingosticks Feb 29, 2016

won't that lint program want these to be more like data.playlist.uri ?

This comment has been minimized.

Copy link
@jcass77

jcass77 Feb 29, 2016

Author Owner

Indeed, I need to run it again after merging the queue saving dialog stuff...

getPlaylists();
});

mopidy.on("event:playlistDeleted", function(data) {
$('#playlisttracksdiv').hide();
delete playlists[data["uri"]];
getPlaylists();
});

mopidy.on("event:volumeChanged", function(data) {
setVolume(data["volume"]);
});
Expand Down
2 changes: 1 addition & 1 deletion mopidy_musicbox_webclient/static/mb.appcache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CACHE MANIFEST

# 2016-02-18:v2
# 2016-02-28:v1

NETWORK:
*
Expand Down

0 comments on commit 2777875

Please sign in to comment.