docbrown/app/javascript/packs/modCenter.jsx
Arit Amana e45742c212
Mod Center MVP 🎉 (#8744)
Co-authored-by: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com>
2020-06-23 14:58:16 -04:00

38 lines
871 B
JavaScript

import { h, render } from 'preact';
import { ModerationArticles } from '../modCenter/moderationArticles';
import { addSnackbarItem, Snackbar } from '../Snackbar';
let elementLoaded = false;
function loadElement() {
const root = document.getElementById('mod-index-list');
const isMobileDevice = typeof window.orientation !== 'undefined';
const snackZone = document.getElementById('snack-zone');
if (root) {
render(<ModerationArticles />, root);
}
if (snackZone) {
render(<Snackbar lifespan="0" />, snackZone);
}
if (isMobileDevice) {
addSnackbarItem({
message: 'The Mod Center is best viewed on desktop.',
addCloseButton: true,
});
}
}
window.InstantClick.on('change', () => {
if (!elementLoaded) {
loadElement();
elementLoaded = true;
}
});
if (!elementLoaded) {
loadElement();
elementLoaded = true;
}