Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show preview if none available #112

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions js/photos.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos.js.map

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions src/components/FolderTagPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
<!-- Images preview -->
<transition name="fade">
<div v-show="loaded"
:class="`folder-content--grid-${fileList.length}`"
:class="`folder-content--grid-${previewList.length}`"
class="folder-content"
role="none">
<img v-for="file in fileList"
<img v-for="file in previewList"
:key="file.fileid"
:src="generateImgSrc(file)"
alt=""
@load="loaded = true">
@load="loaded = true"
@error="onPreviewFail(file)">
</div>
</transition>

Expand Down Expand Up @@ -85,13 +86,14 @@ export default {
data() {
return {
loaded: false,
failed: [],
}
},

computed: {
// folder is empty
isEmpty() {
return this.fileList.length === 0
return this.previewList.length === 0
},

ariaUuid() {
Expand All @@ -101,6 +103,15 @@ export default {
return t('photos', 'Open the "{name}" sub-directory', { name: this.name })
},

/**
* Previews list without the failed ones
* @returns {Object[]} the previews fileinfo
*/
previewList() {
return this.fileList
.filter(file => this.failed.indexOf(file.fileid) === -1)
},

/**
* We do not want encoded slashes when browsing by folder
* so we generate a new valid route object based on the
Expand Down Expand Up @@ -129,6 +140,9 @@ export default {
// use etag to force cache reload if file changed
return generateUrl(`/core/preview?fileId=${fileid}&x=${256}&y=${256}&a=true&v=${etag}`)
},
onPreviewFail({ fileid }) {
this.failed.push(fileid)
},
},
}
</script>
Expand Down