Hide removed images when displaying previous world/avatar images

This commit is contained in:
Natsumi
2021-05-22 22:34:30 +12:00
parent e0e8b36d70
commit 7c0108cf54
+28 -30
View File
@@ -8413,7 +8413,7 @@ speechSynthesis.getVoices();
}); });
} }
} else if (command === 'Previous Images') { } else if (command === 'Previous Images') {
this.displayPreviousImages('User'); this.displayPreviousImages('User', 'Display');
} else if (command === 'Select Avatar') { } else if (command === 'Select Avatar') {
this.promptSelectAvatarDialog(); this.promptSelectAvatarDialog();
} else { } else {
@@ -10980,61 +10980,59 @@ speechSynthesis.getVoices();
var params = { var params = {
fileId fileId
}; };
if (type === 'Avatar') {
if (command === 'Display') { if (command === 'Display') {
this.previousImagesDialogVisible = true; this.previousImagesDialogVisible = true;
this.$nextTick(() => adjustDialogZ(this.$refs.previousImagesDialog.$el)); this.$nextTick(() => adjustDialogZ(this.$refs.previousImagesDialog.$el));
} else if (command === 'Change') { }
if (type === 'Avatar') {
if (command === 'Change') {
this.changeAvatarImageDialogVisible = true; this.changeAvatarImageDialogVisible = true;
this.$nextTick(() => adjustDialogZ(this.$refs.changeAvatarImageDialog.$el)); this.$nextTick(() => adjustDialogZ(this.$refs.changeAvatarImageDialog.$el));
} }
API.getAvatarImages(params).then((args) => { API.getAvatarImages(params).then((args) => {
this.previousImagesTableFileId = args.json.id; this.previousImagesTableFileId = args.json.id;
var images = args.json.versions; var images = args.json.versions;
var imageArray = []; this.checkPreviousImageAvailable(images, command);
images.forEach((image) => {
if (image.file) {
imageArray.push(image.file.url);
}
});
this.previousImagesTable = images;
}); });
} else if (type === 'World') { } else if (type === 'World') {
if (command === 'Display') { if (command === 'Change') {
this.previousImagesDialogVisible = true;
this.$nextTick(() => adjustDialogZ(this.$refs.previousImagesDialog.$el));
} else if (command === 'Change') {
this.changeWorldImageDialogVisible = true; this.changeWorldImageDialogVisible = true;
this.$nextTick(() => adjustDialogZ(this.$refs.changeWorldImageDialog.$el)); this.$nextTick(() => adjustDialogZ(this.$refs.changeWorldImageDialog.$el));
} }
API.getWorldImages(params).then((args) => { API.getWorldImages(params).then((args) => {
this.previousImagesTableFileId = args.json.id; this.previousImagesTableFileId = args.json.id;
var images = args.json.versions; var images = args.json.versions;
var imageArray = []; this.checkPreviousImageAvailable(images, command);
images.forEach((image) => {
if (image.file) {
imageArray.push(image.file.url);
}
});
this.previousImagesTable = images;
}); });
} else if (type === 'User') { } else if (type === 'User') {
this.previousImagesDialogVisible = true;
this.$nextTick(() => adjustDialogZ(this.$refs.previousImagesDialog.$el));
API.getAvatarImages(params).then((args) => { API.getAvatarImages(params).then((args) => {
this.previousImagesTableFileId = args.json.id; this.previousImagesTableFileId = args.json.id;
var images = args.json.versions; var images = args.json.versions;
var imageArray = []; this.checkPreviousImageAvailable(images, command);
images.forEach((image) => {
if (image.file) {
imageArray.push(image.file.url);
}
});
this.previousImagesTable = images;
}); });
} }
}; };
$app.methods.checkPreviousImageAvailable = async function (images, command) {
this.previousImagesTable = [];
for (var image of images) {
if ((image.file) && (image.file.url)) {
var response = await fetch(image.file.url, {
method: 'HEAD',
redirect: 'follow',
headers: {
'User-Agent': appVersion
}
}).catch(error => {
console.log(error);
});
if (response.status === 200) {
this.previousImagesTable.push(image);
}
}
};
};
$app.data.previousImagesDialogVisible = false; $app.data.previousImagesDialogVisible = false;
$app.data.changeAvatarImageDialogVisible = false; $app.data.changeAvatarImageDialogVisible = false;
$app.data.changeAvatarImageDialogLoading = false; $app.data.changeAvatarImageDialogLoading = false;