ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #01205
[Merge] lp:~ahayzen/music-app/refactor-delay-urlhandler-contenthub-after-walkthrough into lp:music-app/refactor
Andrew Hayzen has proposed merging lp:~ahayzen/music-app/refactor-delay-urlhandler-contenthub-after-walkthrough into lp:music-app/refactor.
Commit message:
* Delay urlhandler/content-hub calls until after walkthrough is complete
Requested reviews:
Music App Developers (music-app-dev)
Related bugs:
Bug #1438317 in Ubuntu Music App: "[music] Using content-hub or url-handler on first run causes the walkthrough issues"
https://bugs.launchpad.net/music-app/+bug/1438317
For more details, see:
https://code.launchpad.net/~ahayzen/music-app/refactor-delay-urlhandler-contenthub-after-walkthrough/+merge/254760
* Delay urlhandler/content-hub calls until after walkthrough is complete
Refactor compliment to [0] same testing please :)
0 - https://code.launchpad.net/~ahayzen/music-app/fix-1438317-delay-urlhandler-contenthub-after-walkthrough/+merge/254756
--
Your team Music App Developers is requested to review the proposed merge of lp:~ahayzen/music-app/refactor-delay-urlhandler-contenthub-after-walkthrough into lp:music-app/refactor.
=== modified file 'app/components/Helpers/ContentHubHelper.qml'
--- app/components/Helpers/ContentHubHelper.qml 2015-02-16 20:51:18 +0000
+++ app/components/Helpers/ContentHubHelper.qml 2015-03-31 13:48:14 +0000
@@ -25,6 +25,7 @@
Item {
property var activeTransfer
+ property var delayed: []
property int importId: 0
property list<ContentItem> importItems
property bool processing: contentHubWaitForFile !== -1
@@ -48,51 +49,11 @@
if (activeTransfer.state === ContentTransfer.Charged) {
importItems = activeTransfer.items;
- var processId = importId++;
-
- console.debug("Triggering content-hub import ID", processId);
-
- searchPaths = [];
-
- var err = [];
- var path;
- var res;
- var success = true;
- var url;
-
- for (var i=0; i < importItems.length; i++) {
- url = importItems[i].url.toString()
- console.debug("Triggered content-hub import for item", url)
-
- // fixed path allows for apparmor protection
- path = "~/Music/Imported/" + Qt.formatDateTime(new Date(), "yyyy/MM/dd/hhmmss") + "-" + url.split("/").pop()
- res = contentHub.importFile(importItems[i], path)
-
- if (res !== true) {
- success = false;
- err.push(url.split("/").pop() + " " + res)
- }
- }
-
-
- if (success === true) {
- if (contentHubWaitForFile.processId === -1) {
- contentHubWaitForFile.dialog = PopupUtils.open(Qt.resolvedUrl("../Dialog/ContentHubWaitDialog.qml"), mainView)
- contentHubWaitForFile.searchPaths = contentHub.searchPaths;
- contentHubWaitForFile.processId = processId;
- contentHubWaitForFile.start();
-
- // Stop queue loading in bg
- queueLoaderWorker.canLoad = false
- } else {
- contentHubWaitForFile.searchPaths.push.apply(contentHubWaitForFile.searchPaths, contentHub.searchPaths);
- contentHubWaitForFile.count = 0;
- contentHubWaitForFile.restart();
- }
- }
- else {
- var errordialog = PopupUtils.open(Qt.resolvedUrl("../Dialog/ContentHubErrorDialog.qml"), mainView)
- errordialog.errorText = err.join("\n")
+ if (firstRun) {
+ console.debug("Delaying content-hub import")
+ delayed.push(importItems)
+ } else {
+ contentHub.importRequested(importItems)
}
}
}
@@ -144,6 +105,62 @@
}
}
}
+
+ function importRequested(importItems) {
+ var processId = importId++;
+
+ console.debug("Triggering content-hub import ID", processId);
+
+ searchPaths = [];
+
+ var err = [];
+ var path;
+ var res;
+ var success = true;
+ var url;
+
+ for (var i=0; i < importItems.length; i++) {
+ url = importItems[i].url.toString()
+ console.debug("Triggered content-hub import for item", url)
+
+ // fixed path allows for apparmor protection
+ path = "~/Music/Imported/" + Qt.formatDateTime(new Date(), "yyyy/MM/dd/hhmmss") + "-" + url.split("/").pop()
+ res = contentHub.importFile(importItems[i], path)
+
+ if (res !== true) {
+ success = false;
+ err.push(url.split("/").pop() + " " + res)
+ }
+ }
+
+
+ if (success === true) {
+ if (contentHubWaitForFile.processId === -1) {
+ contentHubWaitForFile.dialog = PopupUtils.open(Qt.resolvedUrl("../Dialog/ContentHubWaitDialog.qml"), mainView)
+ contentHubWaitForFile.searchPaths = contentHub.searchPaths;
+ contentHubWaitForFile.processId = processId;
+ contentHubWaitForFile.start();
+
+ // Stop queue loading in bg
+ queueLoaderWorker.canLoad = false
+ } else {
+ contentHubWaitForFile.searchPaths.push.apply(contentHubWaitForFile.searchPaths, contentHub.searchPaths);
+ contentHubWaitForFile.count = 0;
+ contentHubWaitForFile.restart();
+ }
+ }
+ else {
+ var errordialog = PopupUtils.open(Qt.resolvedUrl("../Dialog/ContentHubErrorDialog.qml"), mainView)
+ errordialog.errorText = err.join("\n")
+ }
+ }
+ }
+
+ function runDelayed() {
+ for (var i=0; i < delayed.length; i++) {
+ console.debug("Running delayed content-hub import")
+ contentHub.importRequested(delayed[i])
+ }
}
Timer {
=== modified file 'app/components/Helpers/UriHandlerHelper.qml'
--- app/components/Helpers/UriHandlerHelper.qml 2015-02-16 20:51:18 +0000
+++ app/components/Helpers/UriHandlerHelper.qml 2015-03-31 13:48:14 +0000
@@ -25,6 +25,8 @@
Item {
id: uriHandler
+ property var delayed: []
+
Connections {
target: UriHandler
@@ -84,7 +86,10 @@
}
function process(uri, play) {
- if (uri.indexOf("album:///") === 0) {
+ if (firstRun) {
+ delayed.push([uri, play])
+ console.debug("Delaying uri call", uri)
+ } else if (uri.indexOf("album:///") === 0) {
processAlbum(uri.substring(9));
} else if (uri.indexOf("file://") === 0) {
processFile(uri.substring(7), play);
@@ -94,4 +99,11 @@
console.debug("Unsupported URI " + uri + ", skipping")
}
}
+
+ function runDelayed() {
+ for (var i=0; i < delayed.length; i++) {
+ console.debug("Running delayed uri call", delayed[i][0])
+ process(delayed[i][0], delayed[i][1])
+ }
+ }
}
=== modified file 'app/music-app.qml'
--- app/music-app.qml 2015-03-24 23:57:29 +0000
+++ app/music-app.qml 2015-03-31 13:48:14 +0000
@@ -48,6 +48,13 @@
property bool firstRun: true
property int queueIndex: 0
property int tabIndex: -1
+
+ onFirstRunChanged: {
+ if (!firstRun) {
+ uriHandler.runDelayed()
+ contentHub.runDelayed()
+ }
+ }
}
// Global keyboard shortcuts
Follow ups