Refresh previews on data change

pull/37/head
Varun Patil 2022-08-20 08:32:32 +00:00
parent 2662225f0f
commit 89f044f125
3 changed files with 31 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -41,24 +41,36 @@ export default {
} }
}, },
mounted() { mounted() {
if (!this.data.previewFileInfos) { this.refreshPreviews();
const folderPath = this.data.path.split('/').slice(3).join('/'); },
dav.getFolderPreviewFileIds(folderPath, 4).then(fileInfos => { watch: {
fileInfos = fileInfos.filter(f => f.hasPreview); data: {
if (fileInfos.length > 0 && fileInfos.length < 4) { handler() {
fileInfos = [fileInfos[0]]; this.refreshPreviews();
} },
this.data.previewFileInfos = fileInfos; },
this.previewFileInfos = fileInfos;
}).catch(() => {
this.data.previewFileInfos = [];
});
} else {
this.previewFileInfos = this.data.previewFileInfos;
}
}, },
methods: { methods: {
/** Refresh previews */
refreshPreviews() {
if (!this.data.previewFileInfos) {
const folderPath = this.data.path.split('/').slice(3).join('/');
dav.getFolderPreviewFileIds(folderPath, 4).then(fileInfos => {
fileInfos = fileInfos.filter(f => f.hasPreview);
if (fileInfos.length > 0 && fileInfos.length < 4) {
fileInfos = [fileInfos[0]];
}
this.data.previewFileInfos = fileInfos;
this.previewFileInfos = fileInfos;
}).catch(() => {
this.data.previewFileInfos = [];
this.previewFileInfos = [];
});
} else {
this.previewFileInfos = this.data.previewFileInfos;
}
},
/** Open album folder */ /** Open album folder */
openFolder(id) { openFolder(id) {
this.$router.push({ name: 'albums', params: { id } }); this.$router.push({ name: 'albums', params: { id } });