From bea22860193ce10efc72ee92de1346dee35eedb1 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 16 Apr 2021 12:39:14 -0500 Subject: [PATCH] Move images in expanded posts from below the extended text to above --- static/js/ctzn-tags/post-view.js | 71 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/static/js/ctzn-tags/post-view.js b/static/js/ctzn-tags/post-view.js index 39b00778..0fc4123d 100644 --- a/static/js/ctzn-tags/post-view.js +++ b/static/js/ctzn-tags/post-view.js @@ -232,8 +232,8 @@ export class PostView extends LitElement {
${unsafeHTML(emojify(linkify(makeSafe(this.post.value.text))))}
- ${this.renderPostExtendedText()} ${this.renderMedia()} + ${this.renderPostExtendedText()} ${this.noctrls ? '' : html` ${this.hasReactionsOrGifts ? html`
@@ -316,36 +316,37 @@ export class PostView extends LitElement { ` } - renderMedia () { - if (!this.post.value.media?.length) { - return '' + renderImg (item, size) { + let url = '' + if (item.blobs.original.dataUrl) { + url = item.blobs.original.dataUrl + } else { + url = BLOB_URL(this.post.author.userId, (item.blobs.thumb || item.blobs.original).blobName) } - const media = this.post.value.media - const img = (item, size) => { - let url = '' - if (item.blobs.original.dataUrl) { - url = item.blobs.original.dataUrl - } else { - url = BLOB_URL(this.post.author.userId, (item.blobs.thumb || item.blobs.original).blobName) - } - return html` -
this.onClickImage(e, item)} + return html` +
this.onClickImage(e, item)} + > + ${item.caption - ${item.caption -
- ` +
+ ` + } + + renderMedia () { + const media = this.post.value.media + if (!media?.length) { + return '' } - if (media.length > 4 && this.mode === 'full') { + if (media.length > 4 && this.mode === 'expanded') { return html`
${repeat(media, item => html` - ${img(item, 'full')} + ${this.renderImg(item, 'full')} `)}
` @@ -355,11 +356,11 @@ export class PostView extends LitElement {
${media.length >= 4 ? html`
-
${img(media[0], 'small')}
-
${img(media[2], 'small')}
+
${this.renderImg(media[0], 'small')}
+
${this.renderImg(media[2], 'small')}
-
${img(media[1], 'small')}
+
${this.renderImg(media[1], 'small')}
${moreImages > 0 ? html` +${moreImages} ` : ''} - ${img(media[3], 'small')} + ${this.renderImg(media[3], 'small')}
` : media.length === 3 ? html` -
${img(media[0], 'big')}
+
${this.renderImg(media[0], 'big')}
-
${img(media[1], 'smaller')}
-
${img(media[2], 'smaller')}
+
${this.renderImg(media[1], 'smaller')}
+
${this.renderImg(media[2], 'smaller')}
` : media.length === 2 ? html` -
${img(media[0], 'medium')}
-
${img(media[1], 'medium')}
+
${this.renderImg(media[0], 'medium')}
+
${this.renderImg(media[1], 'medium')}
` : html` -
${img(media[0], 'big')}
+
${this.renderImg(media[0], 'big')}
`}
`