mirror of
https://github.com/wassname/talk.git
synced 2026-08-18 12:30:39 +08:00
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { Child as PymChild } from "pym.js";
|
|
import React from "react";
|
|
import { StatelessComponent } from "react";
|
|
import ReactDOM from "react-dom";
|
|
|
|
import {
|
|
createContext,
|
|
TalkContext,
|
|
TalkContextProvider,
|
|
} from "talk-framework/lib/bootstrap";
|
|
|
|
import AppContainer from "./containers/AppContainer";
|
|
import {
|
|
onPostMessageAuthError,
|
|
onPostMessageSetAuthToken,
|
|
onPymSetCommentID,
|
|
} from "./listeners";
|
|
import { initLocalState } from "./local";
|
|
import localesData from "./locales";
|
|
|
|
const listeners = [
|
|
onPymSetCommentID,
|
|
onPostMessageSetAuthToken,
|
|
onPostMessageAuthError,
|
|
];
|
|
|
|
// This is called when the context is first initialized.
|
|
async function init(context: TalkContext) {
|
|
await initLocalState(context.relayEnvironment);
|
|
listeners.forEach(f => f(context));
|
|
}
|
|
|
|
async function main() {
|
|
// Bootstrap our context.
|
|
const context = await createContext({
|
|
init,
|
|
localesData,
|
|
userLocales: navigator.languages,
|
|
pym: new PymChild({ polling: 100 }),
|
|
});
|
|
|
|
const Index: StatelessComponent = () => (
|
|
<TalkContextProvider
|
|
value={{ ...context, mediaQueryValues: { width: 640 } }}
|
|
>
|
|
<AppContainer />
|
|
</TalkContextProvider>
|
|
);
|
|
|
|
ReactDOM.render(<Index />, document.getElementById("app"));
|
|
}
|
|
|
|
main();
|