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

View file

@ -980,19 +980,16 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
};
function pushResourceObjectsInTest() {
var isQmlSignaled = false;
for (var i = 0, size = resourceObjectsInTest.length; i < size; ++i) {
if (i in resourceObjectsInTest) {
signalNewResourceObjectInTest(resourceObjectsInTest[i]);
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" });
var maxObjectId = -1;
for (var objectId in resourceObjectsInTest) {
signalNewResourceObjectInTest(resourceObjectsInTest[objectId]);
maxObjectId = (maxObjectId < objectId) ? parseInt(objectId) : maxObjectId;
}
// 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()