From 9d4f18b984d6699bdf96e5f5963edfe80063426c Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sat, 27 Jun 2020 14:22:30 -0500 Subject: Monsterfork v2 Kaiju Commit 2020.06.27.1 - 2020.09.05.5 --- .../flavours/glitch/components/media_gallery.js | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'app/javascript/flavours/glitch/components/media_gallery.js') diff --git a/app/javascript/flavours/glitch/components/media_gallery.js b/app/javascript/flavours/glitch/components/media_gallery.js index 96042f07a..1ab9a6adb 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.js +++ b/app/javascript/flavours/glitch/components/media_gallery.js @@ -384,6 +384,66 @@ class MediaGallery extends React.PureComponent { ); } + let parts = {}; + + media.map( + (attachment, i) => { + if (attachment.get('description')) { + if (attachment.get('description') in parts) { + parts[attachment.get('description')].push([i, attachment.get('url'), attachment.get('id')]); + } else { + parts[attachment.get('description')] = [[i, attachment.get('url'), attachment.get('id')]]; + } + } + }, + ); + + let descriptions = Object.entries(parts).map( + part => { + const [desc, idx] = part; + if (idx.length === 1) { + const url = idx[0][1]; + return ( +

+ + + + + + {desc} +

+ ); + } else if (idx.length !== 0) { + const indexes = ( + + { + idx.map((i, c) => { + const url = i[1]; + return ({c === 0 ? ' ' : ', '}#{1+i[0]}); + }) + } + + ); + return ( +

+ + + + {desc} +

+ ); + } else { + return null; + } + }, + ); + + let description_wrapper = visible && ( +
+ {descriptions} +
+ ); + return (
@@ -396,6 +456,7 @@ class MediaGallery extends React.PureComponent {
{children} + {description_wrapper}
); } -- cgit