about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/containers
diff options
context:
space:
mode:
authorTakeshi Umeda <noel.yoshiba@gmail.com>2020-12-31 07:18:11 +0900
committerClaire <claire.github-309c@sitedethib.com>2021-05-07 22:47:09 +0200
commit34cc6f45acb39aa34d7e24e13b82334a135abbaa (patch)
tree10ae4ec4b759cc8c96f3340f1c278b704fb012c5 /app/javascript/flavours/glitch/containers
parentd8e756eda8b8e838c8bb6bed170aab37fde837b7 (diff)
[Glitch] Fix expand video on public page
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/containers')
-rw-r--r--app/javascript/flavours/glitch/containers/media_container.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/app/javascript/flavours/glitch/containers/media_container.js b/app/javascript/flavours/glitch/containers/media_container.js
index ab5f68770..8657b8064 100644
--- a/app/javascript/flavours/glitch/containers/media_container.js
+++ b/app/javascript/flavours/glitch/containers/media_container.js
@@ -2,7 +2,7 @@ import React, { PureComponent, Fragment } from 'react';
 import ReactDOM from 'react-dom';
 import PropTypes from 'prop-types';
 import { IntlProvider, addLocaleData } from 'react-intl';
-import { List as ImmutableList, fromJS } from 'immutable';
+import { fromJS } from 'immutable';
 import { getLocale } from 'mastodon/locales';
 import { getScrollbarWidth } from 'flavours/glitch/util/scrollbar';
 import MediaGallery from 'flavours/glitch/components/media_gallery';
@@ -31,6 +31,7 @@ export default class MediaContainer extends PureComponent {
     index: null,
     time: null,
     backgroundColor: null,
+    options: null,
   };
 
   handleOpenMedia = (media, index) => {
@@ -40,13 +41,15 @@ export default class MediaContainer extends PureComponent {
     this.setState({ media, index });
   }
 
-  handleOpenVideo = (video, time) => {
-    const media = ImmutableList([video]);
+  handleOpenVideo = (options) => {
+    const { components } = this.props;
+    const { media } = JSON.parse(components[options.componetIndex].getAttribute('data-props'));
+    const mediaList = fromJS(media);
 
     document.body.classList.add('with-modals--active');
     document.documentElement.style.marginRight = `${getScrollbarWidth()}px`;
 
-    this.setState({ media, time });
+    this.setState({ media: mediaList, options });
   }
 
   handleCloseMedia = () => {
@@ -58,6 +61,7 @@ export default class MediaContainer extends PureComponent {
       index: null,
       time: null,
       backgroundColor: null,
+      options: null,
     });
   }
 
@@ -83,6 +87,7 @@ export default class MediaContainer extends PureComponent {
               ...(hashtag ? { hashtag: fromJS(hashtag) } : {}),
 
               ...(componentName === 'Video' ? {
+                componetIndex: i,
                 onOpenVideo: this.handleOpenVideo,
               } : {
                 onOpenMedia: this.handleOpenMedia,
@@ -100,7 +105,9 @@ export default class MediaContainer extends PureComponent {
               <MediaModal
                 media={this.state.media}
                 index={this.state.index || 0}
-                time={this.state.time}
+                currentTime={this.state.options?.startTime}
+                autoPlay={this.state.options?.autoPlay}
+                volume={this.state.options?.defaultVolume}
                 onClose={this.handleCloseMedia}
                 onChangeBackgroundColor={this.setBackgroundColor}
               />