Fix item inbox.

This commit is contained in:
Kasen IO 2020-05-21 21:17:11 -04:00
parent 301bc58e64
commit 5d75c177be
2 changed files with 60 additions and 11 deletions

View file

@ -58,6 +58,10 @@ function onWebAppEventReceived(event) {
sendReceivingItemQueue();
}
if (eventJSON.command == "web-to-script-update-receiving-item-queue") {
updateReceivingItemQueue(eventJSON.data);
}
}
}
@ -80,8 +84,8 @@ function onMessageReceived(channel, message, sender, localOnly) {
var messageJSON = JSON.parse(message);
// Window.alert("Passed 0 " + messageJSON.recipient + " vs " + MyAvatar.sessionUUID);
if (messageJSON.command == "share-item" && messageJSON.recipient == MyAvatar.sessionUUID) { // We are receiving an item.
// Window.alert("Passed 1 " + messageJSON.recipient + " vs " + MyAvatar.sessionUUID);
pushReceivedItemToQueue(sender, messageJSON.type, messageJSON.name, messageJSON.url);
// Window.alert("Passed 1 " + messageJSON.recipient + " vs " + MyAvatar.sessionUUID);
pushReceivedItemToQueue(sender, AvatarList.getAvatar(sender).displayName, messageJSON.type, messageJSON.name, messageJSON.url);
}
}
// print("Message received:");
@ -139,9 +143,10 @@ function loadSettings() {
inventorySettings = Settings.getValue(inventorySettingsString);
}
function pushReceivedItemToQueue(sender, type, name, url) {
function pushReceivedItemToQueue(senderUUID, senderName, type, name, url) {
var packageRequest = {
"sender": sender,
"sender": senderUUID,
"senderName": senderName,
"data": {
"type": type,
"name": name,
@ -160,6 +165,10 @@ function sendReceivingItemQueue() {
sendToWeb("script-to-web-receiving-item-queue", receivingItemQueue);
}
function updateReceivingItemQueue(data) {
receivingItemQueue = data;
}
function sendNearbyUsers() {
var nearbyUsers = AvatarList.getAvatarsInRange(MyAvatar.position, 25); // Find all users within 25m.
var nearbyUsersToSend = [];

View file

@ -162,7 +162,7 @@
>
<v-list-item-content>
<v-list-item-title>{{item.data.name}}</v-list-item-title>
<v-list-item-subtitle>Sent by {{item.sender}}</v-list-item-subtitle>
<v-list-item-subtitle>Sent by {{item.senderName}}</v-list-item-subtitle>
</v-list-item-content>
<v-btn color="success" @click="acceptReceivingItem(item)">
<v-icon>mdi-plus</v-icon>
@ -738,7 +738,28 @@ export default {
receivingItemsDialog: {
show: false,
data: {
receivingItemQueue: [],
receivingItemQueue: [
// {
// "sender": "SENDERUUIDLOL",
// "senderName": "WHOISTHIS1",
// "data": {
// "type": "script",
// "name": "This Is A Real Script",
// "url": "https://butwhythough.com/lol.js",
// "uuid": "This Is A Real Script",
// }
// },
// {
// "sender": "TEST2SENDERUUID",
// "senderName": "WHOTHISBE2",
// "data": {
// "type": "script",
// "name": "REALLYLONGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG",
// "url": "https://butwhythough.com/looool.js",
// "uuid": "REALLYLONNGGGGGGGG",
// }
// }
],
},
},
folderList: [],
@ -974,6 +995,7 @@ export default {
for (var i = 0; i < this.receivingItemsDialog.data.receivingItemQueue.length; i++) {
if (this.receivingItemsDialog.data.receivingItemQueue[i].data.uuid === uuid) {
this.receivingItemsDialog.data.receivingItemQueue.splice(i, 1);
this.sendAppMessage('web-to-script-update-receiving-item-queue', this.receivingItemQueue);
if (this.receivingItemsDialog.data.receivingItemQueue.length === 0) {
this.receivingItemsDialog.show = false; // Close the dialog if there's nothing left.
}
@ -1148,7 +1170,7 @@ export default {
if (Object.prototype.hasOwnProperty.call(indexToSearch[i], "items")) {
// We want to avoid adding the folder itself and also any child folders it may have, putting a folder within its child folder will nuke it.
if (avoidFolder !== indexToSearch[i].uuid) {
console.info("AvoidFolder", avoidFolder, "indexToSearch[i].uuid", indexToSearch[i].uuid);
// console.info("AvoidFolder", avoidFolder, "indexToSearch[i].uuid", indexToSearch[i].uuid);
this.recursiveFolderHoldingList.push({
"name": indexToSearch[i].name,
"uuid": indexToSearch[i].uuid,
@ -1296,6 +1318,9 @@ export default {
});
},
},
shareDialogShow: function() {
return this.$store.state.shareDialog.show;
},
shareDialogStore: {
get() {
return this.$store.state.shareDialog;
@ -1305,8 +1330,6 @@ export default {
property: 'shareDialog',
with: value
});
this.sendAppMessage('web-to-script-request-nearby-users', '')
},
},
removeFolderDialogStore: {
@ -1331,11 +1354,16 @@ export default {
});
},
},
receivingItemQueue: {
get() {
return this.receivingItemsDialog.data.receivingItemQueue;
}
},
receivingItemQueueLength: {
get() {
return this.receivingItemsDialog.data.receivingItemQueue.length;
}
}
},
},
watch: {
// Whenever the item list changes, this will notice and then send it to the script to be saved.
@ -1369,7 +1397,19 @@ export default {
this.getFolderList('editFolder');
}
}
}
},
shareDialogShow: {
handler: function(newVal) {
if (newVal === true) {
this.sendAppMessage('web-to-script-request-nearby-users', '');
}
}
},
receivingItemQueue: {
handler: function() {
}
},
}
};