2016-04-29 03:02:51 +08:00
|
|
|
import React from 'react';
|
2016-05-10 05:19:45 +08:00
|
|
|
import { Router, Route, Redirect, IndexRoute,
|
|
|
|
IndexRedirect, useRouterHistory } from 'react-router';
|
2016-05-10 03:19:52 +08:00
|
|
|
import { createHistory } from 'history';
|
2016-07-07 22:01:40 +08:00
|
|
|
import { isSubscribedForData } from '/imports/ui/components/app/service';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
|
|
|
// route components
|
2016-07-07 22:01:40 +08:00
|
|
|
import AppContainer from '/imports/ui/components/app/container';
|
2016-07-07 22:46:18 +08:00
|
|
|
import { subscribeToCollections, setCredentials } from '/imports/ui/components/app/service';
|
2016-06-02 00:45:01 +08:00
|
|
|
|
2016-07-07 22:01:40 +08:00
|
|
|
import ChatContainer from '/imports/ui/components/chat/container';
|
|
|
|
import UserListContainer from '/imports/ui/components/user-list/container';
|
|
|
|
import Loader from '/imports/ui/components/loader/component';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2016-05-10 03:19:52 +08:00
|
|
|
const browserHistory = useRouterHistory(createHistory)({
|
2016-05-14 00:31:06 +08:00
|
|
|
basename: '/html5client',
|
2016-05-10 03:19:52 +08:00
|
|
|
});
|
2016-05-07 03:12:28 +08:00
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
export const renderRoutes = () => (
|
|
|
|
<Router history={browserHistory}>
|
2016-07-06 02:59:18 +08:00
|
|
|
<Route path="/join/:meetingID/:userID/:authToken" onEnter={setCredentials} />
|
2016-07-07 22:01:40 +08:00
|
|
|
<Route path="/" onEnter={() => {
|
|
|
|
subscribeToCollections()
|
|
|
|
}}
|
|
|
|
getComponent={(nextState, cb) => {
|
|
|
|
subscribeToCollections(() => cb(null, AppContainer));
|
|
|
|
}}>
|
2016-07-06 02:59:18 +08:00
|
|
|
<IndexRoute components={{}} />
|
2016-05-06 23:34:00 +08:00
|
|
|
|
2016-07-07 22:01:40 +08:00
|
|
|
<Route name="users" path="users" getComponents={(nextState, cb) => {
|
|
|
|
subscribeToCollections(() => cb(null, {
|
|
|
|
userList: UserListContainer,
|
|
|
|
}));
|
2016-07-06 02:59:18 +08:00
|
|
|
}} />
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2016-07-07 22:01:40 +08:00
|
|
|
<Route name="chat" path="users/chat/:chatID" getComponents={(nextState, cb) => {
|
|
|
|
subscribeToCollections(() => cb(null, {
|
|
|
|
userList: UserListContainer,
|
|
|
|
chat: ChatContainer,
|
|
|
|
}));
|
2016-07-06 02:59:18 +08:00
|
|
|
}} />
|
2016-07-07 22:01:40 +08:00
|
|
|
|
2016-07-06 02:59:18 +08:00
|
|
|
<Redirect from="users/chat" to="/users/chat/public" />
|
2016-04-29 03:02:51 +08:00
|
|
|
</Route>
|
2016-07-06 02:59:18 +08:00
|
|
|
<Redirect from="*" to="/" />
|
2016-04-29 03:02:51 +08:00
|
|
|
</Router>
|
|
|
|
);
|