about summary refs log tree commit diff
path: root/app/javascript/packs
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-07-15 14:33:15 -0700
committerkibigo! <marrus-sh@users.noreply.github.com>2017-07-15 14:33:15 -0700
commit09cfc079b0958c42fe619e2d88c3f9fd1d7c7900 (patch)
tree156de790a5bec0fdf050e392bee8a64b220d3a9d /app/javascript/packs
parent08d021916db9e350259b925d7e562aa13ba37422 (diff)
parent695439775eacea081c7257aabab39d0ec6b492dc (diff)
Merge upstream (#81)
Diffstat (limited to 'app/javascript/packs')
-rw-r--r--app/javascript/packs/about.js24
-rw-r--r--app/javascript/packs/public.js17
2 files changed, 26 insertions, 15 deletions
diff --git a/app/javascript/packs/about.js b/app/javascript/packs/about.js
new file mode 100644
index 000000000..7b8ab5e5d
--- /dev/null
+++ b/app/javascript/packs/about.js
@@ -0,0 +1,24 @@
+import TimelineContainer from '../mastodon/containers/timeline_container';
+import React from 'react';
+import ReactDOM from 'react-dom';
+import loadPolyfills from '../mastodon/load_polyfills';
+import ready from '../mastodon/ready';
+
+require.context('../images/', true);
+
+function loaded() {
+  const mountNode = document.getElementById('mastodon-timeline');
+
+  if (mountNode !== null) {
+    const props = JSON.parse(mountNode.getAttribute('data-props'));
+    ReactDOM.render(<TimelineContainer {...props} />, mountNode);
+  }
+}
+
+function main() {
+  ready(loaded);
+}
+
+loadPolyfills().then(main).catch(error => {
+  console.error(error);
+});
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js
index 06cc1b53a..4865f3ec0 100644
--- a/app/javascript/packs/public.js
+++ b/app/javascript/packs/public.js
@@ -5,9 +5,7 @@ import emojify from '../mastodon/emoji';
 import { getLocale } from '../mastodon/locales';
 import loadPolyfills from '../mastodon/load_polyfills';
 import { processBio } from '../glitch/util/bio_metadata';
-import TimelineContainer from '../mastodon/containers/timeline_container';
-import React from 'react';
-import ReactDOM from 'react-dom';
+import ready from '../mastodon/ready';
 
 require.context('../images/', true);
 
@@ -40,21 +38,10 @@ function loaded() {
     const datetime = new Date(content.getAttribute('datetime'));
     content.textContent = relativeFormat.format(datetime);;
   });
-
-  const mountNode = document.getElementById('mastodon-timeline');
-
-  if (mountNode !== null) {
-    const props = JSON.parse(mountNode.getAttribute('data-props'));
-    ReactDOM.render(<TimelineContainer {...props} />, mountNode);
-  }
 }
 
 function main() {
-  if (['interactive', 'complete'].includes(document.readyState)) {
-    loaded();
-  } else {
-    document.addEventListener('DOMContentLoaded', loaded);
-  }
+  ready(loaded);
 
   delegate(document, '.video-player video', 'click', ({ target }) => {
     if (target.paused) {