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

Proposed by Victor Thompson on 2014-10-19
Status: Merged
Approved by: Andrew Hayzen on 2014-10-20
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 2014-10-19 Approve on 2014-10-20
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2014-10-19
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.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MusicPlaylists.qml'
2--- MusicPlaylists.qml 2014-09-20 10:50:45 +0000
3+++ MusicPlaylists.qml 2014-10-19 06:29:48 +0000
4@@ -23,6 +23,7 @@
5 import Ubuntu.Components.Popups 1.0
6 import QtMultimedia 5.0
7 import QtQuick.LocalStorage 2.0
8+import "meta-database.js" as Library
9 import "settings.js" as Settings
10 import "scrobble.js" as Scrobble
11 import "playlists.js" as Playlists
12@@ -86,6 +87,11 @@
13 if (Playlists.renamePlaylist(oldPlaylistName, playlistName.text) === true) {
14 playlistModel.filterPlaylists()
15
16+ if (Library.recentContainsPlaylist(oldPlaylistName)) {
17+ Library.recentRenamePlaylist(oldPlaylistName, playlistName.text)
18+ recentModel.filterRecent()
19+ }
20+
21 PopupUtils.close(dialogEditPlaylist)
22
23 if (inPlaylist) {
24@@ -144,6 +150,12 @@
25 Playlists.removePlaylist(model.name)
26
27 playlistModel.filterPlaylists();
28+
29+ if (Library.recentContainsPlaylist(model.name)) {
30+ Library.recentRemovePlaylist(model.name)
31+ mainView.hasRecent = !Library.isRecentEmpty()
32+ recentModel.filterRecent()
33+ }
34 }
35 }
36
37
38=== modified file 'meta-database.js'
39--- meta-database.js 2014-09-12 02:57:30 +0000
40+++ meta-database.js 2014-10-19 06:29:48 +0000
41@@ -103,6 +103,37 @@
42 return res;
43 }
44
45+function recentContainsPlaylist(key) {
46+ var db = getDatabase();
47+ var rs;
48+ db.transaction( function(tx) {
49+ rs = tx.executeSql("SELECT count(*) as value FROM recent WHERE type=? AND key=?",
50+ ["playlist", key]);
51+ }
52+ );
53+ return rs.rows.item(0).value > 0;
54+}
55+
56+function recentRemovePlaylist(key) {
57+ var res = false
58+ var db = getDatabase();
59+ db.transaction( function(tx) {
60+ res = tx.executeSql("DELETE FROM recent WHERE type=? AND key=?",
61+ ["playlist", key]).rowsAffected > 0;
62+
63+ })
64+ return res
65+}
66+
67+function recentRenamePlaylist(oldKey, newKey) {
68+ var db = getDatabase();
69+ db.transaction( function(tx) {
70+ tx.executeSql("UPDATE recent SET title=?,key=? WHERE type=? AND key=?",
71+ [newKey, newKey, "playlist", oldKey]);
72+
73+ })
74+}
75+
76 function isRecentEmpty() {
77 var db = getDatabase();
78 var res = 0;

Subscribers

People subscribed via source and target branches

to status/vote changes: