From 45895eee6b93a40f433a442d13829d1339f82801 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 12 Jun 2023 16:40:17 -0300 Subject: content: generateAdditionalFilesList: remove redundant fileSize opt --- .../dependencies/generateAdditionalFilesList.js | 9 ++++----- .../dependencies/generateAlbumAdditionalFilesList.js | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateAdditionalFilesList.js b/src/content/dependencies/generateAdditionalFilesList.js index 56e6686c..f698f032 100644 --- a/src/content/dependencies/generateAdditionalFilesList.js +++ b/src/content/dependencies/generateAdditionalFilesList.js @@ -30,11 +30,10 @@ export default { 'language', ], - data(additionalFiles, {fileSize = true} = {}) { + data(additionalFiles) { return { // Additional files are already a serializable format. additionalFiles, - showFileSizes: fileSize, }; }, @@ -52,7 +51,7 @@ export default { html, language, }) { - if (!slots.fileSizes) { + if (!slots.fileLinks) { return html.blank(); } @@ -61,7 +60,7 @@ export default { .filter(([key, value]) => value) .map(([key]) => key)); - if (filesWithLinks.size === 0) { + if (empty(filesWithLinks)) { return html.blank(); } @@ -91,7 +90,7 @@ export default { html.tag('ul', files.map(file => html.tag('li', - (slots.fileSizes[file] + (slots.fileSizes?.[file] ? language.$('releaseInfo.additionalFiles.file.withSize', { file: slots.fileLinks[file], size: language.formatFileSize(slots.fileSizes[file]), diff --git a/src/content/dependencies/generateAlbumAdditionalFilesList.js b/src/content/dependencies/generateAlbumAdditionalFilesList.js index 5fd4e05b..23f32bf5 100644 --- a/src/content/dependencies/generateAlbumAdditionalFilesList.js +++ b/src/content/dependencies/generateAlbumAdditionalFilesList.js @@ -6,23 +6,21 @@ export default { extraDependencies: [ 'getSizeOfAdditionalFile', + 'html', 'urls', ], - data(album, additionalFiles, {fileSize = true} = {}) { + data(album, additionalFiles) { return { albumDirectory: album.directory, fileLocations: additionalFiles.flatMap(({files}) => files), - showFileSizes: fileSize, }; }, - relations(relation, album, additionalFiles, {fileSize = true} = {}) { + relations(relation, album, additionalFiles) { return { additionalFilesList: - relation('generateAdditionalFilesList', additionalFiles, { - fileSize, - }), + relation('generateAdditionalFilesList', additionalFiles), additionalFileLinks: Object.fromEntries( @@ -35,7 +33,11 @@ export default { }; }, - generate(data, relations, { + slots: { + showFileSizes: {type: 'boolean', default: true}, + }, + + generate(data, relations, slots, { getSizeOfAdditionalFile, urls, }) { @@ -45,7 +47,7 @@ export default { fileSizes: Object.fromEntries(data.fileLocations.map(file => [ file, - (data.showFileSizes + (slots.showFileSizes ? getSizeOfAdditionalFile( urls .from('media.root') -- cgit 1.3.0-6-gf8a5