Invite images can only be png's

This commit is contained in:
Natsumi
2021-02-23 02:28:53 +13:00
parent 20ab4278c3
commit 4347da4fa7
2 changed files with 39 additions and 11 deletions

View File

@@ -3689,7 +3689,7 @@ speechSynthesis.getVoices();
if ((this.isGameRunning) && ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends') || (this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP') ||
(this.sharedFeedFilters.noty.OnPlayerJoining === 'Friends') || (this.sharedFeedFilters.noty.OnPlayerJoining === 'VIP'))) {
var bias = new Date(Date.now() - 120000).toJSON();
var locationBias = new Date(Date.now() - 10000).toJSON();
var locationBias = new Date(Date.now() - 15000).toJSON(); //15 seconds
for (var i = 0; i < wristFeed.length; i++) {
var ctx = wristFeed[i];
if ((ctx.created_at < bias) || (ctx.type === 'Location')) {
@@ -3780,7 +3780,7 @@ speechSynthesis.getVoices();
}
// on Location change remove OnPlayerJoined
if ((ctx.type === 'Location') && (this.hideOnPlayerJoined)) {
var locationBias = new Date(Date.parse(ctx.created_at) + 10000).toJSON(); //10 seconds
var locationBias = new Date(Date.parse(ctx.created_at) + 15000).toJSON(); //15 seconds
for (var k = w - 1; k > -1; k--) {
var feedItem = wristArr[k];
if ((feedItem.created_at > locationBias) || (feedItem.type === 'Location')) {
@@ -8734,12 +8734,12 @@ speechSynthesis.getVoices();
json,
params
};
this.$emit('FILES', args);
this.$emit('VRCPLUSICON:LIST', args);
return args;
});
};
API.$on('FILES', function (args) {
API.$on('VRCPLUSICON:LIST', function (args) {
$app.VRCPlusIconsTable = args.json;
});
@@ -8774,11 +8774,22 @@ speechSynthesis.getVoices();
$app.methods.deleteVRCPlusIcon = function (userIcon) {
API.deleteVRCPlusIcon(userIcon).then((args) => {
this.displayVRCPlusIconsTable();
API.$emit('VRCPLUSICON:DELETE', args);
return args;
});
};
API.$on('VRCPLUSICON:DELETE', function (args) {
var array = $app.VRCPlusIconsTable;
var { length } = array;
for (var i = 0; i < length; ++i) {
if (args.userIcon === array[i].id) {
array.splice(i, 1);
break;
}
}
});
API.deleteVRCPlusIcon = function (userIcon) {
return this.call(`file/${userIcon}`, {
method: 'DELETE'
@@ -8805,6 +8816,11 @@ speechSynthesis.getVoices();
};
$app.methods.onFileChangeVRCPlusIcon = function (e) {
var clearFile = function() {
if (document.querySelector('#VRCPlusIconUploadButton')) {
document.querySelector('#VRCPlusIconUploadButton').value = '';
}
};
var files = e.target.files || e.dataTransfer.files;
if (!files.length) {
return;
@@ -8814,6 +8830,7 @@ speechSynthesis.getVoices();
message: 'File size too large',
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
@@ -8821,6 +8838,7 @@ speechSynthesis.getVoices();
message: 'File isn\'t an image',
type: 'error'
});
clearFile();
return;
}
var r = new FileReader();
@@ -8835,6 +8853,7 @@ speechSynthesis.getVoices();
});
};
r.readAsBinaryString(files[0]);
clearFile();
};
$app.methods.displayVRCPlusIconUpload = function () {
@@ -8850,10 +8869,17 @@ speechSynthesis.getVoices();
json,
params
};
this.$emit('VRCPLUSICON:ADD', args);
return args;
});
};
API.$on('VRCPLUSICON:ADD', function (args) {
if (Object.keys($app.VRCPlusIconsTable).length !== 0) {
$app.VRCPlusIconsTable.push(args.json);
}
});
$app.data.uploadImage = '';
$app.methods.inviteImageUpload = function (e) {
@@ -8866,13 +8892,15 @@ speechSynthesis.getVoices();
message: 'File size too large',
type: 'error'
});
this.clearInviteImageUpload();
return;
}
if (!files[0].type.match(/image.*/)) {
if (!files[0].type.match(/image.png/)) {
$app.$message({
message: 'File isn\'t an image',
message: 'File isn\'t a png',
type: 'error'
});
this.clearInviteImageUpload();
return;
}
var r = new FileReader();