index.js 814 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { render, Component } from "inferno";
  2. import Login from "./Login";
  3. import Matrix from "./Matrix";
  4. import * as localforage from "localforage";
  5. import { setPushGateway } from "./utils";
  6. import "./index.css";
  7. class App extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. login: null,
  12. };
  13. localforage.getItem("login").then((login) => {
  14. this.setState({ login: login });
  15. });
  16. }
  17. componentWillMount() {
  18. if (!window.navigator.onLine) {
  19. window.alert("Sorry but I cannot work without the Internet!");
  20. window.close();
  21. }
  22. }
  23. render() {
  24. if (this.state.login === null) {
  25. return <Login />;
  26. } else {
  27. return <Matrix login={this.state.login} />;
  28. }
  29. }
  30. }
  31. setPushGateway();
  32. render(<App />, document.getElementById("root"));