Changes:
- Refactored articleForm.jsx by moving loadForm() before document.ready.then()
- Removed 'function' in .then() and modified to .then(() => {
- Removed unused function 'isUserSignedIn' in Onboarding.jsx
See: #2470
42 lines
1,003 B
JavaScript
42 lines
1,003 B
JavaScript
import { h, render } from 'preact';
|
|
import { getUserDataAndCsrfToken } from '../chat/util';
|
|
import ArticleForm from '../article-form/articleForm';
|
|
|
|
HTMLDocument.prototype.ready = new Promise(resolve => {
|
|
if (document.readyState !== 'loading') {
|
|
return resolve();
|
|
}
|
|
document.addEventListener('DOMContentLoaded', () => resolve());
|
|
return null;
|
|
});
|
|
|
|
function loadForm() {
|
|
getUserDataAndCsrfToken().then(({ currentUser, csrfToken }) => {
|
|
window.currentUser = currentUser;
|
|
window.csrfToken = csrfToken;
|
|
|
|
const root = document.getElementById('article-form');
|
|
const { article, organizations, version } = root.dataset;
|
|
|
|
render(
|
|
<ArticleForm
|
|
article={article}
|
|
organizations={organizations}
|
|
version={version}
|
|
/>,
|
|
root,
|
|
root.firstElementChild,
|
|
);
|
|
});
|
|
}
|
|
|
|
document.ready.then(() => {
|
|
loadForm();
|
|
window.InstantClick.on('change', () => {
|
|
if (document.getElementById('article-form')) {
|
|
loadForm();
|
|
}
|
|
});
|
|
});
|
|
|
|
|