about summary refs log tree commit diff
path: root/app/javascript/packs
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2018-05-09 23:22:52 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-05-09 16:22:52 +0200
commit16fee0335f2b10b0ce54f71965d2f2acc0e24942 (patch)
tree9a29c227620fc320841feb073077dbb00b0b4a66 /app/javascript/packs
parentdc010cc77a1e34a1f65b9a522b299bac6aa44329 (diff)
Show card modal on public pages (#7428)
Diffstat (limited to 'app/javascript/packs')
-rw-r--r--app/javascript/packs/public.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js
index 7096b9b4f..3a1f1a16b 100644
--- a/app/javascript/packs/public.js
+++ b/app/javascript/packs/public.js
@@ -25,7 +25,6 @@ function main() {
   const { getLocale } = require('../mastodon/locales');
   const { localeData } = getLocale();
   const VideoContainer = require('../mastodon/containers/video_container').default;
-  const CardContainer = require('../mastodon/containers/card_container').default;
   const React = require('react');
   const ReactDOM = require('react-dom');
 
@@ -75,10 +74,16 @@ function main() {
       ReactDOM.render(<VideoContainer locale={locale} {...props} />, content);
     });
 
-    [].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => {
-      const props = JSON.parse(content.getAttribute('data-props'));
-      ReactDOM.render(<CardContainer locale={locale} {...props} />, content);
-    });
+    const cards = document.querySelectorAll('[data-component="Card"]');
+
+    if (cards.length > 0) {
+      import(/* webpackChunkName: "containers/cards_container" */ '../mastodon/containers/cards_container').then(({ default: CardsContainer }) => {
+        const content = document.createElement('div');
+
+        ReactDOM.render(<CardsContainer locale={locale} cards={cards} />, content);
+        document.body.appendChild(content);
+      }).catch(error => console.error(error));
+    }
 
     const mediaGalleries = document.querySelectorAll('[data-component="MediaGallery"]');