edit-meta: check update permissions

pull/465/head
Varun Patil 2023-03-09 17:19:43 -08:00
parent 6c8ea158c0
commit f3bdccb1ce
1 changed files with 37 additions and 10 deletions

View File

@ -143,24 +143,21 @@ export default defineComponent({
// Check if already quit // Check if already quit
if (!this.show || this.state !== state) return; if (!this.show || this.state !== state) return;
// Check for anything invalid // Use valid photos
const invalid = photos.filter((p) => !p.imageInfo); const valid = this.filterValid(photos);
if (invalid.length > 0) { if (valid.length === 0) {
showError( this.close();
this.t("memories", "Failed to load metadata for {n} photos.", { return;
n: invalid.length,
})
);
photos = photos.filter((p) => p.imageInfo);
} }
this.photos = photos; this.photos = valid;
this.processing = false; this.processing = false;
}, },
close() { close() {
this.photos = null; this.photos = null;
this.show = false; this.show = false;
this.processing = false;
}, },
async save() { async save() {
@ -239,6 +236,36 @@ export default defineComponent({
this.emitRefresh(true); this.emitRefresh(true);
}, },
filterValid(photos: IPhoto[]) {
// Check if we have image info
const valid = photos.filter((p) => p.imageInfo);
if (valid.length !== photos.length) {
showError(
this.t("memories", "Failed to load metadata for {n} photos.", {
n: photos.length - valid.length,
})
);
}
// Check if photos are updatable
const updatable = valid.filter((p) =>
p.imageInfo?.permissions?.includes("U")
);
if (updatable.length !== valid.length) {
showError(
this.t(
"memories",
"{n} photos cannot be edited (permissions error).",
{
n: valid.length - updatable.length,
}
)
);
}
return updatable;
},
}, },
}); });
</script> </script>