Move image upload buttons, bug fixes

This commit is contained in:
Natsumi
2021-10-25 20:27:54 +13:00
parent 1c567d4ab4
commit 07551fb0a8
2 changed files with 136 additions and 26 deletions

View File

@@ -5712,11 +5712,15 @@ speechSynthesis.getVoices();
);
}
if (this.saveCredentials) {
savedCredentials[currentUser.username].loginParmas =
this.saveCredentials;
var credentialsToSave = {
user: currentUser,
loginParmas: this.saveCredentials
};
savedCredentials[currentUser.username] = credentialsToSave;
delete this.saveCredentials;
}
if (typeof savedCredentials[currentUser.username] !== 'undefined') {
} else if (
typeof savedCredentials[currentUser.username] !== 'undefined'
) {
savedCredentials[currentUser.username].user = currentUser;
savedCredentials[currentUser.username].cookies =
await webApiService.getCookies();
@@ -11449,9 +11453,6 @@ speechSynthesis.getVoices();
case 'Rename':
this.promptRenameWorld(D);
break;
case 'Upload Image':
document.getElementById('WorldImageUploadButton').click();
break;
case 'Change Image':
this.displayPreviousImages('World', 'Change');
break;
@@ -11461,6 +11462,9 @@ speechSynthesis.getVoices();
case 'Change Description':
this.promptChangeWorldDescription(D);
break;
case 'Download Unity Package':
this.openExternalLink(this.worldDialog.ref.unityPackageUrl);
break;
default:
this.$confirm(`Continue? ${command}`, 'Confirm', {
confirmButtonText: 'Confirm',
@@ -11657,9 +11661,6 @@ speechSynthesis.getVoices();
case 'Rename':
this.promptRenameAvatar(D);
break;
case 'Upload Image':
document.getElementById('AvatarImageUploadButton').click();
break;
case 'Change Image':
this.displayPreviousImages('Avatar', 'Change');
break;
@@ -12539,6 +12540,12 @@ speechSynthesis.getVoices();
});
$app.methods.setVRCPlusIcon = function (fileId) {
if (!API.currentUser.$isVRCPlus) {
this.$message({
message: 'VRCPlus required',
type: 'error'
});
}
var userIcon = '';
if (fileId) {
userIcon = `https://api.vrchat.cloud/api/1/file/${fileId}/1`;
@@ -12587,6 +12594,18 @@ speechSynthesis.getVoices();
});
};
API.deleteFileVersion = function (params) {
return this.call(`file/${params.fileId}/${params.version}`, {
method: 'DELETE'
}).then((json) => {
var args = {
json,
params
};
return args;
});
};
$app.methods.compareCurrentVRCPlusIcon = function (userIcon) {
var currentUserIcon = extractFileId(API.currentUser.userIcon);
if (userIcon === currentUserIcon) {
@@ -13613,6 +13632,7 @@ speechSynthesis.getVoices();
return;
}
this.avatarDialog.loading = true;
this.changeAvatarImageDialogLoading = true;
var r = new FileReader();
r.onload = async function (file) {
var base64File = btoa(r.result);
@@ -13688,6 +13708,7 @@ speechSynthesis.getVoices();
method: 'PUT'
});
$app.avatarDialog.loading = false;
$app.changeAvatarImageDialogLoading = false;
};
API.$on('AVATARIMAGE:INIT', function (args) {
@@ -13748,6 +13769,7 @@ speechSynthesis.getVoices();
.then((json) => {
if (json.status !== 200) {
$app.avatarDialog.loading = false;
$app.changeAvatarImageDialogLoading = false;
this.$throw('Avatar image upload failed', json);
}
var args = {
@@ -13844,6 +13866,7 @@ speechSynthesis.getVoices();
.then((json) => {
if (json.status !== 200) {
$app.avatarDialog.loading = false;
$app.changeAvatarImageDialogLoading = false;
this.$throw('Avatar image upload failed', json);
}
var args = {
@@ -13943,6 +13966,7 @@ speechSynthesis.getVoices();
return;
}
this.worldDialog.loading = true;
this.changeWorldImageDialogLoading = true;
var r = new FileReader();
r.onload = async function (file) {
var base64File = btoa(r.result);
@@ -14018,6 +14042,7 @@ speechSynthesis.getVoices();
method: 'PUT'
});
$app.worldDialog.loading = false;
$app.changeWorldImageDialogLoading = false;
};
API.$on('WORLDIMAGE:INIT', function (args) {
@@ -14078,6 +14103,7 @@ speechSynthesis.getVoices();
.then((json) => {
if (json.status !== 200) {
$app.worldDialog.loading = false;
$app.changeWorldImageDialogLoading = false;
this.$throw('World image upload failed', json);
}
var args = {
@@ -14174,6 +14200,7 @@ speechSynthesis.getVoices();
.then((json) => {
if (json.status !== 200) {
$app.worldDialog.loading = false;
$app.changeWorldImageDialogLoading = false;
this.$throw('World image upload failed', json);
}
var args = {
@@ -14240,11 +14267,13 @@ speechSynthesis.getVoices();
API.$on('AVATARIMAGE:SET', function (args) {
$app.avatarDialog.loading = false;
$app.changeAvatarImageDialogLoading = false;
if (args.json.imageUrl === args.params.imageUrl) {
$app.$message({
message: 'Avatar image changed',
type: 'success'
});
$app.displayPreviousImages('Avatar', 'Change');
} else {
this.$throw(0, 'Avatar image change failed');
}
@@ -14267,11 +14296,13 @@ speechSynthesis.getVoices();
API.$on('WORLDIMAGE:SET', function (args) {
$app.worldDialog.loading = false;
$app.changeWorldImageDialogLoading = false;
if (args.json.imageUrl === args.params.imageUrl) {
$app.$message({
message: 'World image changed',
type: 'success'
});
$app.displayPreviousImages('World', 'Change');
} else {
this.$throw(0, 'World image change failed');
}
@@ -14312,7 +14343,12 @@ speechSynthesis.getVoices();
}
API.getAvatarImages(params).then((args) => {
this.previousImagesTableFileId = args.json.id;
var images = args.json.versions.reverse();
var images = [];
args.json.versions.forEach((item) => {
if (!item.deleted) {
images.unshift(item);
}
});
this.checkPreviousImageAvailable(images);
});
} else if (type === 'World') {
@@ -14324,13 +14360,23 @@ speechSynthesis.getVoices();
}
API.getWorldImages(params).then((args) => {
this.previousImagesTableFileId = args.json.id;
var images = args.json.versions.reverse();
var images = [];
args.json.versions.forEach((item) => {
if (!item.deleted) {
images.unshift(item);
}
});
this.checkPreviousImageAvailable(images);
});
} else if (type === 'User') {
API.getAvatarImages(params).then((args) => {
this.previousImagesTableFileId = args.json.id;
var images = args.json.versions.reverse();
var images = [];
args.json.versions.forEach((item) => {
if (!item.deleted) {
images.unshift(item);
}
});
this.checkPreviousImageAvailable(images);
});
}
@@ -14430,6 +14476,32 @@ speechSynthesis.getVoices();
});
};
$app.methods.uploadAvatarImage = function () {
document.getElementById('AvatarImageUploadButton').click();
};
$app.methods.deleteAvatarImage = function () {
this.changeAvatarImageDialogLoading = true;
var parmas = {
fileId: this.previousImagesTableFileId,
version: this.previousImagesTable[0].version
};
API.deleteFileVersion(parmas)
.then((args) => {
this.previousImagesTableFileId = args.json.id;
var images = [];
args.json.versions.forEach((item) => {
if (!item.deleted) {
images.unshift(item);
}
});
this.checkPreviousImageAvailable(images);
})
.finally(() => {
this.changeAvatarImageDialogLoading = false;
});
};
$app.methods.setWorldImage = function (image) {
this.changeWorldImageDialogLoading = true;
var parmas = {
@@ -14442,6 +14514,32 @@ speechSynthesis.getVoices();
});
};
$app.methods.uploadWorldImage = function () {
document.getElementById('WorldImageUploadButton').click();
};
$app.methods.deleteWorldImage = function () {
this.changeWorldImageDialogLoading = true;
var parmas = {
fileId: this.previousImagesTableFileId,
version: this.previousImagesTable[0].version
};
API.deleteFileVersion(parmas)
.then((args) => {
this.previousImagesTableFileId = args.json.id;
var images = [];
args.json.versions.forEach((item) => {
if (!item.deleted) {
images.unshift(item);
}
});
this.checkPreviousImageAvailable(images);
})
.finally(() => {
this.changeWorldImageDialogLoading = false;
});
};
$app.methods.compareCurrentImage = function (image) {
if (
`https://api.vrchat.cloud/api/1/file/${this.previousImagesTableFileId}/${image.version}/file` ===
@@ -15497,6 +15595,12 @@ speechSynthesis.getVoices();
});
$app.methods.setProfilePicOverride = function (fileId) {
if (!API.currentUser.$isVRCPlus) {
this.$message({
message: 'VRCPlus required',
type: 'error'
});
}
var profilePicOverride = '';
if (fileId) {
profilePicOverride = `https://api.vrchat.cloud/api/1/file/${fileId}/1`;
@@ -15910,7 +16014,6 @@ speechSynthesis.getVoices();
key !== API.currentUser.id
) {
API.cachedUsers.delete(key);
console.log(key);
}
});
API.cachedWorlds.forEach((value, key) => {
@@ -15919,7 +16022,6 @@ speechSynthesis.getVoices();
value.authorId !== API.currentUser.id
) {
API.cachedWorlds.delete(key);
console.log(key);
}
});
API.cachedAvatars.forEach((value, key) => {
@@ -15928,7 +16030,6 @@ speechSynthesis.getVoices();
value.authorId !== API.currentUser.id
) {
API.cachedAvatars.delete(key);
console.log(key);
}
});