2021-04-18 06:58:57 +02:00
|
|
|
import { Nitro, RoomSessionEvent } from 'nitro-renderer';
|
2021-06-22 11:52:47 +02:00
|
|
|
import { FC, useCallback, useEffect, useState } from 'react';
|
2021-04-14 23:47:02 +02:00
|
|
|
import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event';
|
2021-05-12 11:23:15 +02:00
|
|
|
import { AvatarEditorView } from '../avatar-editor/AvatarEditorView';
|
2021-04-22 05:26:30 +02:00
|
|
|
import { CatalogView } from '../catalog/CatalogView';
|
2021-04-22 08:54:49 +02:00
|
|
|
import { FriendListView } from '../friend-list/FriendListView';
|
2021-04-14 20:24:24 +02:00
|
|
|
import { HotelView } from '../hotel-view/HotelView';
|
2021-04-22 05:18:44 +02:00
|
|
|
import { InventoryView } from '../inventory/InventoryView';
|
2021-04-18 06:58:57 +02:00
|
|
|
import { NavigatorView } from '../navigator/NavigatorView';
|
2021-06-22 11:52:47 +02:00
|
|
|
import { NotificationCenterView } from '../notification-center/NotificationCenterView';
|
2021-04-15 19:29:48 +02:00
|
|
|
import { RightSideView } from '../right-side/RightSideView';
|
2021-04-18 06:58:57 +02:00
|
|
|
import { RoomHostView } from '../room-host/RoomHostView';
|
2021-04-14 20:24:24 +02:00
|
|
|
import { ToolbarView } from '../toolbar/ToolbarView';
|
|
|
|
import { MainViewProps } from './MainView.types';
|
|
|
|
|
2021-06-22 11:52:47 +02:00
|
|
|
export const MainView: FC<MainViewProps> = props =>
|
2021-04-14 20:24:24 +02:00
|
|
|
{
|
2021-04-15 08:24:12 +02:00
|
|
|
const [ isReady, setIsReady ] = useState(false);
|
2021-04-18 06:58:57 +02:00
|
|
|
const [ landingViewVisible, setLandingViewVisible ] = useState(true);
|
2021-04-14 23:47:02 +02:00
|
|
|
|
2021-04-15 08:24:12 +02:00
|
|
|
const onRoomSessionEvent = useCallback((event: RoomSessionEvent) =>
|
2021-04-14 23:47:02 +02:00
|
|
|
{
|
2021-04-18 06:58:57 +02:00
|
|
|
switch(event.type)
|
|
|
|
{
|
|
|
|
case RoomSessionEvent.CREATED:
|
|
|
|
setLandingViewVisible(false);
|
|
|
|
return;
|
|
|
|
case RoomSessionEvent.ENDED:
|
|
|
|
setLandingViewVisible(event.openLandingView);
|
|
|
|
return;
|
|
|
|
}
|
2021-04-15 08:24:12 +02:00
|
|
|
}, []);
|
2021-04-14 23:47:02 +02:00
|
|
|
|
|
|
|
useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent);
|
|
|
|
useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent);
|
|
|
|
|
2021-04-14 20:24:24 +02:00
|
|
|
useEffect(() =>
|
|
|
|
{
|
2021-04-15 08:24:12 +02:00
|
|
|
setIsReady(true);
|
|
|
|
|
2021-04-14 20:24:24 +02:00
|
|
|
Nitro.instance.communication.connection.onReady();
|
2021-04-15 08:24:12 +02:00
|
|
|
}, []);
|
2021-04-14 20:24:24 +02:00
|
|
|
|
|
|
|
return (
|
2021-04-19 18:34:31 +02:00
|
|
|
<div className="nitro-main">
|
2021-04-18 06:58:57 +02:00
|
|
|
{ landingViewVisible && <HotelView /> }
|
2021-06-23 05:22:32 +02:00
|
|
|
<ToolbarView isInRoom={ !landingViewVisible } />
|
2021-04-18 06:58:57 +02:00
|
|
|
<RoomHostView />
|
2021-05-12 11:23:15 +02:00
|
|
|
<AvatarEditorView />
|
2021-04-19 18:34:31 +02:00
|
|
|
<NavigatorView />
|
2021-04-22 05:18:44 +02:00
|
|
|
<InventoryView />
|
2021-04-22 05:26:30 +02:00
|
|
|
<CatalogView />
|
2021-04-22 08:54:49 +02:00
|
|
|
<FriendListView />
|
2021-04-19 18:34:31 +02:00
|
|
|
<RightSideView />
|
2021-06-22 11:52:47 +02:00
|
|
|
<NotificationCenterView />
|
2021-04-14 20:24:24 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|