aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/Main.tsx
blob: acc74e914349ca37cac0e97bc534161ad5393d4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// if ((module as any).hot) {
//     (module as any).hot.accept();
// }

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AssignAllExtensions } from "../../extensions/General/Extensions";
import { Docs } from "../documents/Documents";
import { CurrentUserUtils } from "../util/CurrentUserUtils";
import { LinkManager } from "../util/LinkManager";
import { ReplayMovements } from '../util/ReplayMovements';
import { TrackMovements } from "../util/TrackMovements";
import { CollectionView } from "./collections/CollectionView";
import { DashboardView } from './DashboardView';
import { MainView } from "./MainView";

AssignAllExtensions();

(async () => {
    MainView.Live = window.location.search.includes("live");
    window.location.search.includes("safe") && CollectionView.SetSafeMode(true);
    const info = await CurrentUserUtils.loadCurrentUser();
    if (info.id !== "__guest__") {
        // a guest will not have an id registered
        await CurrentUserUtils.loadUserDocument(info.id);
    } else {
        await Docs.Prototypes.initialize();
    }
    document.getElementById('root')!.addEventListener('wheel', event => {
        if (event.ctrlKey) {
            event.preventDefault();
        }
    }, true);
    const startload = (document as any).startLoad;
    const loading = Date.now() - (startload ? Number(startload) : (Date.now() - 3000));
    console.log("Load Time = " + loading);
    const d = new Date();
    d.setTime(d.getTime() + (100 * 24 * 60 * 60 * 1000));
    const expires = "expires=" + d.toUTCString();
    document.cookie = `loadtime=${loading};${expires};path=/`;
    new LinkManager();
    new TrackMovements();
    new ReplayMovements();
    ReactDOM.render(<MainView />, document.getElementById('root'));
})();