diff --git a/app/javascript/flavours/glitch/components/media_gallery.js b/app/javascript/flavours/glitch/components/media_gallery.js index 6a0500cd5..b048d6413 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.js +++ b/app/javascript/flavours/glitch/components/media_gallery.js @@ -358,11 +358,53 @@ export default class MediaGallery extends React.PureComponent { ); } - let descriptions; - descriptions = media.take(6).map( + let parts = {}; + + media.map( (attachment, i) => { - if (attachment.get('description')) - return

Attachment {1+i}: {attachment.get('description')}

+ 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 => { + let [desc, idx] = part; + if (idx.length == 1) { + let url = idx[0][1]; + return ( +

+ + + Attachment #{1+idx[0][0]} + + + {': '} {desc} +

+ ); + } else if (idx.length != 0) { + let c=0; + return ( +

+ + Attachments + { + idx.map(i => { + let url = i[1]; + c++; + return ({c == 1 ? ' ' : ', '}#{1+i[0]}); + }) + } + + {': '} {desc} +

+ ); + } } );