Frontend: Only show thumbs for which a hash exists
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
1f3d9ca758
commit
9c72a2168c
2 changed files with 31 additions and 6 deletions
|
@ -102,7 +102,7 @@ class Photo extends RestModel {
|
|||
refreshFileAttr() {
|
||||
const file = this.mainFile();
|
||||
|
||||
if (!file) {
|
||||
if (!file || !file.FileHash) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,11 @@ class Thumb extends Model {
|
|||
let result = [];
|
||||
|
||||
photos.forEach((p) => {
|
||||
result.push(this.fromPhoto(p));
|
||||
let thumb = this.fromPhoto(p);
|
||||
|
||||
if(thumb) {
|
||||
result.push(thumb);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
|
@ -40,11 +44,15 @@ class Thumb extends Model {
|
|||
return this.fromFile(photo, photo.Files.find(f => !!f.FilePrimary));
|
||||
}
|
||||
|
||||
if(!photo || !photo.FileHash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const result = {
|
||||
uuid: photo.PhotoUUID,
|
||||
title: photo.PhotoTitle,
|
||||
favorite: photo.PhotoFavorite,
|
||||
download_url: "/api/v1/download/" + photo.FileHash,
|
||||
download_url: this.downloadUrl(photo),
|
||||
original_w: photo.FileWidth,
|
||||
original_h: photo.FileHeight,
|
||||
};
|
||||
|
@ -63,11 +71,15 @@ class Thumb extends Model {
|
|||
}
|
||||
|
||||
static fromFile(photo, file) {
|
||||
if(!photo || !file || !file.FileHash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const result = {
|
||||
uuid: photo.PhotoUUID,
|
||||
title: photo.PhotoTitle,
|
||||
favorite: photo.PhotoFavorite,
|
||||
download_url: "/api/v1/download/" + file.FileHash,
|
||||
download_url: this.downloadUrl(file),
|
||||
original_w: file.FileWidth,
|
||||
original_h: file.FileHeight,
|
||||
};
|
||||
|
@ -92,8 +104,12 @@ class Thumb extends Model {
|
|||
if (!p.Files) return;
|
||||
|
||||
p.Files.forEach((f) => {
|
||||
if (f.FileType === "jpg") {
|
||||
result.push(this.fromFile(p, f));
|
||||
if (f && f.FileType === "jpg") {
|
||||
let thumb = this.fromFile(p, f);
|
||||
|
||||
if(thumb) {
|
||||
result.push(thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -132,6 +148,15 @@ class Thumb extends Model {
|
|||
|
||||
return "/api/v1/thumbnails/" + file.FileHash + "/" + type;
|
||||
}
|
||||
|
||||
static downloadUrl(file) {
|
||||
if (!file || !file.FileHash) {
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
return "/api/v1/download/" + file.FileHash;
|
||||
}
|
||||
}
|
||||
|
||||
export default Thumb;
|
||||
|
|
Loading…
Reference in a new issue