about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/packs
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-05-17 16:45:19 +0200
committerThibaut Girka <thib@sitedethib.com>2018-05-17 18:37:00 +0200
commitdd1d98f9cf405104ef106ee5f376bd09815dac42 (patch)
tree6d8a797aad14e7640ca2ffaa6395aa8f322895e8 /app/javascript/flavours/glitch/packs
parent4bf43e6f3e93643d989a2872763b41505fab2206 (diff)
[Glitch] Show card modal on public pages
Port 16fee0335f2b10b0ce54f71965d2f2acc0e24942 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/packs')
-rw-r--r--app/javascript/flavours/glitch/packs/public.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/javascript/flavours/glitch/packs/public.js b/app/javascript/flavours/glitch/packs/public.js
index ed685b6b7..4e621c67f 100644
--- a/app/javascript/flavours/glitch/packs/public.js
+++ b/app/javascript/flavours/glitch/packs/public.js
@@ -7,7 +7,6 @@ function main() {
   const { getLocale } = require('locales');
   const { localeData } = getLocale();
   const VideoContainer = require('flavours/glitch/containers/video_container').default;
-  const CardContainer = require('flavours/glitch/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"]');