Merge lp:~vthompson/music-app/fix-1382170 into lp:music-app/trusty

Proposed by Victor Thompson
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 649
Merged at revision: 649
Proposed branch: lp:~vthompson/music-app/fix-1382170
Merge into: lp:music-app/trusty
Diff against target: 78 lines (+43/-0)
2 files modified
MusicPlaylists.qml (+12/-0)
meta-database.js (+31/-0)
To merge this branch: bzr merge lp:~vthompson/music-app/fix-1382170
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+238812@code.launchpad.net

Commit message

Fix playlist deletion and renaming in recent table

Description of the change

Fix playlist deletion and renaming in recent table. Adds some functions for modifying the recently played table. This is a fairly minimal fix, but it should encompass every playlist rename and deletion case with regard to the recent list/table.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

LGTM :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MusicPlaylists.qml'
--- MusicPlaylists.qml 2014-09-20 10:50:45 +0000
+++ MusicPlaylists.qml 2014-10-19 06:29:48 +0000
@@ -23,6 +23,7 @@
23import Ubuntu.Components.Popups 1.023import Ubuntu.Components.Popups 1.0
24import QtMultimedia 5.024import QtMultimedia 5.0
25import QtQuick.LocalStorage 2.025import QtQuick.LocalStorage 2.0
26import "meta-database.js" as Library
26import "settings.js" as Settings27import "settings.js" as Settings
27import "scrobble.js" as Scrobble28import "scrobble.js" as Scrobble
28import "playlists.js" as Playlists29import "playlists.js" as Playlists
@@ -86,6 +87,11 @@
86 if (Playlists.renamePlaylist(oldPlaylistName, playlistName.text) === true) {87 if (Playlists.renamePlaylist(oldPlaylistName, playlistName.text) === true) {
87 playlistModel.filterPlaylists()88 playlistModel.filterPlaylists()
8889
90 if (Library.recentContainsPlaylist(oldPlaylistName)) {
91 Library.recentRenamePlaylist(oldPlaylistName, playlistName.text)
92 recentModel.filterRecent()
93 }
94
89 PopupUtils.close(dialogEditPlaylist)95 PopupUtils.close(dialogEditPlaylist)
9096
91 if (inPlaylist) {97 if (inPlaylist) {
@@ -144,6 +150,12 @@
144 Playlists.removePlaylist(model.name)150 Playlists.removePlaylist(model.name)
145151
146 playlistModel.filterPlaylists();152 playlistModel.filterPlaylists();
153
154 if (Library.recentContainsPlaylist(model.name)) {
155 Library.recentRemovePlaylist(model.name)
156 mainView.hasRecent = !Library.isRecentEmpty()
157 recentModel.filterRecent()
158 }
147 }159 }
148 }160 }
149161
150162
=== modified file 'meta-database.js'
--- meta-database.js 2014-09-12 02:57:30 +0000
+++ meta-database.js 2014-10-19 06:29:48 +0000
@@ -103,6 +103,37 @@
103 return res;103 return res;
104}104}
105105
106function recentContainsPlaylist(key) {
107 var db = getDatabase();
108 var rs;
109 db.transaction( function(tx) {
110 rs = tx.executeSql("SELECT count(*) as value FROM recent WHERE type=? AND key=?",
111 ["playlist", key]);
112 }
113 );
114 return rs.rows.item(0).value > 0;
115}
116
117function recentRemovePlaylist(key) {
118 var res = false
119 var db = getDatabase();
120 db.transaction( function(tx) {
121 res = tx.executeSql("DELETE FROM recent WHERE type=? AND key=?",
122 ["playlist", key]).rowsAffected > 0;
123
124 })
125 return res
126}
127
128function recentRenamePlaylist(oldKey, newKey) {
129 var db = getDatabase();
130 db.transaction( function(tx) {
131 tx.executeSql("UPDATE recent SET title=?,key=? WHERE type=? AND key=?",
132 [newKey, newKey, "playlist", oldKey]);
133
134 })
135}
136
106function isRecentEmpty() {137function isRecentEmpty() {
107 var db = getDatabase();138 var db = getDatabase();
108 var res = 0;139 var res = 0;

Subscribers

People subscribed via source and target branches

to status/vote changes: