Merge lp:~vthompson/music-app/improve-playlist-delete into lp:music-app/remix

Proposed by Victor Thompson
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 862
Merged at revision: 857
Proposed branch: lp:~vthompson/music-app/improve-playlist-delete
Merge into: lp:music-app/remix
Diff against target: 58 lines (+7/-17)
2 files modified
common/SongsPage.qml (+2/-11)
playlists.js (+5/-6)
To merge this branch: bzr merge lp:~vthompson/music-app/improve-playlist-delete
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Andrew Hayzen Approve
Review via email: mp+255237@code.launchpad.net

Commit message

Improve multiselect delete for playlist items

Description of the change

Improve multiselect delete for playlist items

To post a comment you must log in.
858. By Victor Thompson

Remove returns

859. By Victor Thompson

Remove returns

860. By Victor Thompson

Remove returns

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
861. By Victor Thompson

reuse removeFromPlaylist()

862. By Victor Thompson

Execute within a single transaction.

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

This is now super quick :)

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

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 2015-03-29 22:11:54 +0000
3+++ common/SongsPage.qml 2015-04-05 16:00:16 +0000
4@@ -208,16 +208,7 @@
5 text: i18n.tr("Delete")
6 visible: songStackPage.line1 === i18n.tr("Playlist")
7 onTriggered: {
8- for (var i=0; i < albumtrackslist.selectedItems.length; i++) {
9- Playlists.removeFromPlaylist(songStackPage.line2, albumtrackslist.selectedItems[i])
10-
11- // Update indexes as an index has been removed
12- for (var j=i + 1; j < albumtrackslist.selectedItems.length; j++) {
13- if (albumtrackslist.selectedItems[j] > albumtrackslist.selectedItems[i]) {
14- albumtrackslist.selectedItems[j]--;
15- }
16- }
17- }
18+ Playlists.removeFromPlaylist(songStackPage.line2, albumtrackslist.selectedItems)
19
20 albumtrackslist.closeSelection()
21
22@@ -486,7 +477,7 @@
23 id: playlistRemoveAction
24 sourceComponent: Remove {
25 onTriggered: {
26- Playlists.removeFromPlaylist(songStackPage.line2, model.i)
27+ Playlists.removeFromPlaylist(songStackPage.line2, [model.i])
28
29 playlistChangedHelper() // update recent/playlist models
30
31
32=== modified file 'playlists.js'
33--- playlists.js 2015-01-25 16:44:49 +0000
34+++ playlists.js 2015-04-05 16:00:16 +0000
35@@ -367,18 +367,17 @@
36 return res
37 }
38
39-function removeFromPlaylist(playlist, index) {
40+function removeFromPlaylist(playlist, indexes) {
41 var db = getPlaylistDatabase()
42- var res = false
43
44 db.transaction(function (tx) {
45- res = tx.executeSql('DELETE FROM track WHERE playlist=? AND i=?;',
46- [playlist, index]).rowsAffected > 0
47+ for (var i = 0; i < indexes.length; i++) {
48+ tx.executeSql('DELETE FROM track WHERE playlist=? AND i=?;',
49+ [playlist, indexes[i]]).rowsAffected > 0
50+ }
51
52 reorder(playlist, "remove", tx)
53 })
54-
55- return res
56 }
57
58 function reorder(playlist, type, tx) {

Subscribers

People subscribed via source and target branches