Un-wear things when trashing them if worn

This commit is contained in:
Zach Fox 2018-12-19 15:16:48 -08:00
parent 46e00cf1b3
commit d0998174ff
2 changed files with 32 additions and 8 deletions

View file

@ -313,6 +313,10 @@ Item {
Commerce.uninstallApp(root.itemHref); Commerce.uninstallApp(root.itemHref);
} }
} }
onVisibleChanged: {
trashButton.updateProperties();
}
} }
Loader { Loader {
@ -342,6 +346,10 @@ Item {
}); });
} }
} }
onVisibleChanged: {
trashButton.updateProperties();
}
} }
Loader { Loader {
@ -355,6 +363,20 @@ Item {
onLoaded: { onLoaded: {
item.buttonGlyphText = hifi.glyphs.trash; item.buttonGlyphText = hifi.glyphs.trash;
updateProperties();
item.buttonClicked = function() {
sendToPurchases({method: 'showTrashLightbox',
isInstalled: root.isInstalled,
itemHref: root.itemHref,
itemName: root.itemName,
certID: root.certificateId,
itemType: root.itemType,
wornEntityID: root.wornEntityID
});
}
}
function updateProperties() {
if (updateButton.visible && uninstallButton.visible) { if (updateButton.visible && uninstallButton.visible) {
item.buttonText = ""; item.buttonText = "";
item.glyphSize = 20; item.glyphSize = 20;
@ -362,14 +384,6 @@ Item {
item.buttonText = "Send to Trash"; item.buttonText = "Send to Trash";
item.glyphSize = 30; item.glyphSize = 30;
} }
item.buttonClicked = function() {
sendToPurchases({method: 'showTrashLightbox',
isInstalled: root.isInstalled,
itemHref: root.itemHref,
itemName: root.itemName,
certID: root.certificateId
});
}
} }
} }
} }

View file

@ -664,6 +664,16 @@ Rectangle {
if (msg.isInstalled) { if (msg.isInstalled) {
Commerce.uninstallApp(msg.itemHref); Commerce.uninstallApp(msg.itemHref);
} }
if (MyAvatar.skeletonModelURL === msg.itemHref) {
MyAvatar.useFullAvatarURL('');
}
if (msg.itemType === "wearable" && msg.wornEntityID !== '') {
Entities.deleteEntity(msg.wornEntityID);
purchasesModel.setProperty(index, 'wornEntityID', '');
}
Commerce.transferAssetToUsername("trashbot", msg.certID, 1, "Sent " + msg.itemName + " to trash."); Commerce.transferAssetToUsername("trashbot", msg.certID, 1, "Sent " + msg.itemName + " to trash.");
lightboxPopup.titleText = '"' + msg.itemName + '" Sent to Trash'; lightboxPopup.titleText = '"' + msg.itemName + '" Sent to Trash';