about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/status/components/card.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-10-29 14:56:53 +0100
committerThibG <thib@sitedethib.com>2018-10-30 17:51:06 +0100
commitb21615e9579a6f33ed1cdf6fc37fc8a1ff24a0d5 (patch)
tree6bbfa982ed1bff2acae14f202c7d10df3a749d65 /app/javascript/flavours/glitch/features/status/components/card.js
parentac9780b8449527a6a7ab5e2031eeb37f7f2291e7 (diff)
[Glitch] Fix dimensions of preview cards, fix crash in web UI, fix warning
Port 9c38c5daa3d7298f02c763a84a74680dcc89dac2 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/features/status/components/card.js')
-rw-r--r--app/javascript/flavours/glitch/features/status/components/card.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/features/status/components/card.js b/app/javascript/flavours/glitch/features/status/components/card.js
index 9a87f7a3f..743fe779a 100644
--- a/app/javascript/flavours/glitch/features/status/components/card.js
+++ b/app/javascript/flavours/glitch/features/status/components/card.js
@@ -59,7 +59,7 @@ export default class Card extends React.PureComponent {
     card: ImmutablePropTypes.map,
     maxDescription: PropTypes.number,
     onOpenMedia: PropTypes.func.isRequired,
-    compact: PropTypes.boolean,
+    compact: PropTypes.bool,
   };
 
   static defaultProps = {
@@ -120,7 +120,7 @@ export default class Card extends React.PureComponent {
     const content   = { __html: addAutoPlay(card.get('html')) };
     const { width } = this.state;
     const ratio     = card.get('width') / card.get('height');
-    const height    = card.get('width') > card.get('height') ? (width / ratio) : (width * ratio);
+    const height    = width / ratio;
 
     return (
       <div
@@ -145,8 +145,8 @@ export default class Card extends React.PureComponent {
     const interactive = card.get('type') !== 'link';
     const className   = classnames('status-card', { horizontal, compact, interactive });
     const title       = interactive ? <a className='status-card__title' href={card.get('url')} title={card.get('title')} rel='noopener' target='_blank'><strong>{card.get('title')}</strong></a> : <strong className='status-card__title' title={card.get('title')}>{card.get('title')}</strong>;
-    const ratio       = compact ? 16 / 9 : card.get('width') / card.get('height');
-    const height      = card.get('width') > card.get('height') ? (width / ratio) : (width * ratio);
+    const ratio       = card.get('width') / card.get('height');
+    const height      = (compact && !embedded) ? (width / (16 / 9)) : (width / ratio);
 
     const description = (
       <div className='status-card__content'>