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
1=== modified file 'MusicNowPlaying.qml'
2--- MusicNowPlaying.qml 2015-01-23 07:22:52 +0000
3+++ MusicNowPlaying.qml 2015-01-25 20:07:19 +0000
4@@ -491,7 +491,7 @@
5 state: ""
6
7 leftSideAction: Remove {
8- onTriggered: trackQueue.removeQueue(index)
9+ onTriggered: trackQueue.removeQueueList([index])
10 }
11 multiselectable: true
12 reorderable: true
13
14=== modified file 'meta-database.js'
15--- meta-database.js 2015-01-20 23:58:27 +0000
16+++ meta-database.js 2015-01-25 20:07:19 +0000
17@@ -123,26 +123,6 @@
18 })
19 }
20
21-function removeQueueItem(ind) {
22- var db = getDatabase()
23- var res = false
24-
25- db.transaction(function (tx) {
26- tx.executeSql('DELETE FROM queue WHERE ind=?;', [ind])
27-
28- var rs = tx.executeSql('SELECT MAX(ind) FROM queue')
29-
30- var lastIndex = isQueueEmpty() ? 0 : rs.rows.item(0)["MAX(ind)"]
31-
32- for(var i = ind+1; i <= lastIndex; i++) {
33- tx.executeSql('UPDATE queue SET ind=? WHERE ind=?;',
34- [i-1, i])
35- }
36- })
37-
38- return res
39-}
40-
41
42 // Optimised removeQueue for removing multiple tracks from the queue
43 function removeQueueList(list)
44
45=== modified file 'music-app.qml'
46--- music-app.qml 2015-01-25 16:44:49 +0000
47+++ music-app.qml 2015-01-25 20:07:19 +0000
48@@ -904,27 +904,6 @@
49 queueIndex = 0 // reset otherwise when you append and play 1 track it doesn't update correctly
50 }
51
52- function removeQueue(index)
53- {
54- var removedIndex = index
55-
56- if (trackQueue.model.count === 1) {
57- player.stop()
58- musicToolbar.goBack()
59- } else if (index === player.currentIndex) {
60- player.nextSong(player.isPlaying);
61- }
62-
63- trackQueue.model.remove(index);
64- Library.removeQueueItem(removedIndex);
65-
66- if (removedIndex < player.currentIndex) {
67- // update index as the old has been removed
68- player.currentIndex -= 1;
69- queueIndex -= 1;
70- }
71- }
72-
73 // Optimised removeQueue for removing multiple tracks from the queue
74 function removeQueueList(items)
75 {

Subscribers

People subscribed via source and target branches