Merge lp:~vthompson/music-app/remove-single-item-performance into lp:music-app/remix

Proposed by Victor Thompson
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 811
Merged at revision: 811
Proposed branch: lp:~vthompson/music-app/remove-single-item-performance
Merge into: lp:music-app/remix
Diff against target: 75 lines (+1/-42)
3 files modified
MusicNowPlaying.qml (+1/-1)
meta-database.js (+0/-20)
music-app.qml (+0/-21)
To merge this branch: bzr merge lp:~vthompson/music-app/remove-single-item-performance
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+247536@code.launchpad.net

Commit message

* Use removeQueueList() for single items for performance
* Remove removeQueue() and removeQueueItem()

Description of the change

* Use removeQueueList() for single items for performance
* Remove removeQueue() and removeQueueItem()

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, *massively* improves deletion on large queues :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'MusicNowPlaying.qml'
--- MusicNowPlaying.qml 2015-01-23 07:22:52 +0000
+++ MusicNowPlaying.qml 2015-01-25 20:07:19 +0000
@@ -491,7 +491,7 @@
491 state: ""491 state: ""
492492
493 leftSideAction: Remove {493 leftSideAction: Remove {
494 onTriggered: trackQueue.removeQueue(index)494 onTriggered: trackQueue.removeQueueList([index])
495 }495 }
496 multiselectable: true496 multiselectable: true
497 reorderable: true497 reorderable: true
498498
=== modified file 'meta-database.js'
--- meta-database.js 2015-01-20 23:58:27 +0000
+++ meta-database.js 2015-01-25 20:07:19 +0000
@@ -123,26 +123,6 @@
123 })123 })
124}124}
125125
126function removeQueueItem(ind) {
127 var db = getDatabase()
128 var res = false
129
130 db.transaction(function (tx) {
131 tx.executeSql('DELETE FROM queue WHERE ind=?;', [ind])
132
133 var rs = tx.executeSql('SELECT MAX(ind) FROM queue')
134
135 var lastIndex = isQueueEmpty() ? 0 : rs.rows.item(0)["MAX(ind)"]
136
137 for(var i = ind+1; i <= lastIndex; i++) {
138 tx.executeSql('UPDATE queue SET ind=? WHERE ind=?;',
139 [i-1, i])
140 }
141 })
142
143 return res
144}
145
146126
147// Optimised removeQueue for removing multiple tracks from the queue127// Optimised removeQueue for removing multiple tracks from the queue
148function removeQueueList(list)128function removeQueueList(list)
149129
=== modified file 'music-app.qml'
--- music-app.qml 2015-01-25 16:44:49 +0000
+++ music-app.qml 2015-01-25 20:07:19 +0000
@@ -904,27 +904,6 @@
904 queueIndex = 0 // reset otherwise when you append and play 1 track it doesn't update correctly904 queueIndex = 0 // reset otherwise when you append and play 1 track it doesn't update correctly
905 }905 }
906906
907 function removeQueue(index)
908 {
909 var removedIndex = index
910
911 if (trackQueue.model.count === 1) {
912 player.stop()
913 musicToolbar.goBack()
914 } else if (index === player.currentIndex) {
915 player.nextSong(player.isPlaying);
916 }
917
918 trackQueue.model.remove(index);
919 Library.removeQueueItem(removedIndex);
920
921 if (removedIndex < player.currentIndex) {
922 // update index as the old has been removed
923 player.currentIndex -= 1;
924 queueIndex -= 1;
925 }
926 }
927
928 // Optimised removeQueue for removing multiple tracks from the queue907 // Optimised removeQueue for removing multiple tracks from the queue
929 function removeQueueList(items)908 function removeQueueList(items)
930 {909 {

Subscribers

People subscribed via source and target branches