about summary refs log tree commit diff
path: root/app/javascript/packs/public.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-05-10 00:28:54 +0200
committerGitHub <noreply@github.com>2018-05-10 00:28:54 +0200
commit34142ab29c33104793afe3199f102d84b83b9b57 (patch)
treeafba23a3f169d7445f80ffe555985a295c98f6e1 /app/javascript/packs/public.js
parent143878d9dadd03347c54c9261b9bc754a1d0f5bc (diff)
parent5d8052e7156c913a551b923c51d508b1ea8837b3 (diff)
Merge pull request #472 from ThibG/glitch-soc/merge
Merge upstream changes
Diffstat (limited to 'app/javascript/packs/public.js')
-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 3377c2329..38aaf895f 100644
--- a/app/javascript/packs/public.js
+++ b/app/javascript/packs/public.js
@@ -7,7 +7,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');
 
@@ -57,10 +56,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"]');