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

Proposed by Victor Thompson
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 675
Merged at revision: 676
Proposed branch: lp:~vthompson/music-app/remix-fix-1382170
Merge into: lp:music-app/remix
Diff against target: 70 lines (+42/-0)
2 files modified
common/SongsPage.qml (+11/-0)
meta-database.js (+31/-0)
To merge this branch: bzr merge lp:~vthompson/music-app/remix-fix-1382170
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+238784@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
1=== modified file 'common/SongsPage.qml'
2--- common/SongsPage.qml 2014-10-16 23:36:00 +0000
3+++ common/SongsPage.qml 2014-10-18 03:54:01 +0000
4@@ -365,6 +365,11 @@
5 if (Playlists.renamePlaylist(playlistName.placeholderText, playlistName.text) === true) {
6 playlistModel.filterPlaylists()
7
8+ if (Library.recentContainsPlaylist(playlistName.placeholderText)) {
9+ Library.recentRenamePlaylist(playlistName.placeholderText, playlistName.text)
10+ recentModel.filterRecent()
11+ }
12+
13 PopupUtils.close(dialogEditPlaylist)
14
15 line2 = playlistName.text
16@@ -406,6 +411,12 @@
17
18 playlistModel.filterPlaylists();
19
20+ if (Library.recentContainsPlaylist(dialogRemovePlaylist.oldPlaylistName)) {
21+ Library.recentRemovePlaylist(dialogRemovePlaylist.oldPlaylistName)
22+ mainView.hasRecent = !Library.isRecentEmpty()
23+ recentModel.filterRecent()
24+ }
25+
26 PopupUtils.close(dialogRemovePlaylist)
27
28 musicToolbar.goBack()
29
30=== modified file 'meta-database.js'
31--- meta-database.js 2014-09-12 02:57:30 +0000
32+++ meta-database.js 2014-10-18 03:54:01 +0000
33@@ -103,6 +103,37 @@
34 return res;
35 }
36
37+function recentContainsPlaylist(key) {
38+ var db = getDatabase();
39+ var rs;
40+ db.transaction( function(tx) {
41+ rs = tx.executeSql("SELECT count(*) as value FROM recent WHERE type=? AND key=?",
42+ ["playlist", key]);
43+ }
44+ );
45+ return rs.rows.item(0).value > 0;
46+}
47+
48+function recentRemovePlaylist(key) {
49+ var res = false
50+ var db = getDatabase();
51+ db.transaction( function(tx) {
52+ res = tx.executeSql("DELETE FROM recent WHERE type=? AND key=?",
53+ ["playlist", key]).rowsAffected > 0;
54+
55+ })
56+ return res
57+}
58+
59+function recentRenamePlaylist(oldKey, newKey) {
60+ var db = getDatabase();
61+ db.transaction( function(tx) {
62+ tx.executeSql("UPDATE recent SET title=?,key=? WHERE type=? AND key=?",
63+ [newKey, newKey, "playlist", oldKey]);
64+
65+ })
66+}
67+
68 function isRecentEmpty() {
69 var db = getDatabase();
70 var res = 0;

Subscribers

People subscribed via source and target branches