Use persistent object id counter

This commit is contained in:
Kerry Ivan Kurian 2018-09-24 23:57:48 -07:00
parent ca1da9c830
commit ff83713365
2 changed files with 17 additions and 21 deletions

View file

@ -26,13 +26,11 @@ Rectangle {
id: root id: root
property string installedApps property string installedApps
property var nextResourceObjectId: 0
signal sendToScript(var message) signal sendToScript(var message)
HifiStylesUit.HifiConstants { id: hifi } HifiStylesUit.HifiConstants { id: hifi }
ListModel { ListModel { id: resourceListModel }
id: resourceListModel
property var nextId: 0
}
color: hifi.colors.white color: hifi.colors.white
@ -52,7 +50,8 @@ Rectangle {
resourceListModel.append(resourceObject); resourceListModel.append(resourceObject);
spinner.visible = false; spinner.visible = false;
break; break;
case "marketplaceTestBackendIsAlive": case "nextObjectIdInTest":
nextResourceObjectId = message.id;
spinner.visible = false; spinner.visible = false;
break; break;
} }
@ -65,14 +64,14 @@ Rectangle {
resource.match(/\.json\.gz$/) ? "content set" : resource.match(/\.json\.gz$/) ? "content set" :
resource.match(/\.json$/) ? "entity or wearable" : resource.match(/\.json$/) ? "entity or wearable" :
"unknown"); "unknown");
return { "id": resourceListModel.nextId++, return { "id": nextResourceObjectId++,
"resource": resource, "resource": resource,
"assetType": assetType }; "assetType": assetType };
} }
function installResourceObj(resourceObj) { function installResourceObj(resourceObj) {
if ("application" == resourceObj["assetType"]) { if ("application" == resourceObj.assetType) {
Commerce.installApp(resourceObj["resource"]); Commerce.installApp(resourceObj.resource);
} }
} }
@ -269,7 +268,7 @@ Rectangle {
sendToScript({ sendToScript({
method: 'tester_newResourceObject', method: 'tester_newResourceObject',
resourceObject: resourceObj }); resourceObject: resourceObj });
} }
} }
Repeater { Repeater {

View file

@ -980,19 +980,16 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
}; };
function pushResourceObjectsInTest() { function pushResourceObjectsInTest() {
var isQmlSignaled = false; var maxObjectId = -1;
for (var i = 0, size = resourceObjectsInTest.length; i < size; ++i) { for (var objectId in resourceObjectsInTest) {
if (i in resourceObjectsInTest) { signalNewResourceObjectInTest(resourceObjectsInTest[objectId]);
signalNewResourceObjectInTest(resourceObjectsInTest[i]); maxObjectId = (maxObjectId < objectId) ? parseInt(objectId) : maxObjectId;
isQmlSignaled = true;
}
}
// Be sure that the QML has heard from us, at least so that it
// can indicate to the user that all of the resoruce objects in
// test have been transmitted to it.
if (!isQmlSignaled) {
ui.tablet.sendToQml({ method: "marketplaceTestBackendIsAlive" });
} }
// N.B. Thinking about removing the following sendToQml? Be sure
// that the marketplace item tester QML has heard from us, at least
// so that it can indicate to the user that all of the resoruce
// objects in test have been transmitted to it.
ui.tablet.sendToQml({ method: "nextObjectIdInTest", id: maxObjectId + 1 });
} }
// Function Name: onTabletScreenChanged() // Function Name: onTabletScreenChanged()