2021-07-28 16:15:52 +03:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
|
|
|
import cons from '../../../client/state/cons';
|
|
|
|
import navigation from '../../../client/state/navigation';
|
|
|
|
|
|
|
|
import InviteList from '../invite-list/InviteList';
|
2021-08-31 16:13:31 +03:00
|
|
|
import PublicRooms from '../public-rooms/PublicRooms';
|
|
|
|
import CreateRoom from '../create-room/CreateRoom';
|
2021-07-28 16:15:52 +03:00
|
|
|
import InviteUser from '../invite-user/InviteUser';
|
|
|
|
import Settings from '../settings/Settings';
|
2022-01-29 10:18:06 +02:00
|
|
|
import SpaceSettings from '../space-settings/SpaceSettings';
|
2021-07-28 16:15:52 +03:00
|
|
|
|
|
|
|
function Windows() {
|
|
|
|
const [isInviteList, changeInviteList] = useState(false);
|
2021-08-31 16:13:31 +03:00
|
|
|
const [publicRooms, changePublicRooms] = useState({
|
2021-08-08 12:15:21 +03:00
|
|
|
isOpen: false, searchTerm: undefined,
|
|
|
|
});
|
2021-08-31 16:13:31 +03:00
|
|
|
const [isCreateRoom, changeCreateRoom] = useState(false);
|
2021-08-08 07:53:26 +03:00
|
|
|
const [inviteUser, changeInviteUser] = useState({
|
|
|
|
isOpen: false, roomId: undefined, term: undefined,
|
|
|
|
});
|
2021-07-28 16:15:52 +03:00
|
|
|
const [settings, changeSettings] = useState(false);
|
|
|
|
|
|
|
|
function openInviteList() {
|
|
|
|
changeInviteList(true);
|
|
|
|
}
|
2021-08-31 16:13:31 +03:00
|
|
|
function openPublicRooms(searchTerm) {
|
|
|
|
changePublicRooms({
|
2021-08-08 12:15:21 +03:00
|
|
|
isOpen: true,
|
|
|
|
searchTerm,
|
|
|
|
});
|
2021-07-28 16:15:52 +03:00
|
|
|
}
|
2021-08-31 16:13:31 +03:00
|
|
|
function openCreateRoom() {
|
|
|
|
changeCreateRoom(true);
|
2021-07-28 16:15:52 +03:00
|
|
|
}
|
2021-08-08 07:53:26 +03:00
|
|
|
function openInviteUser(roomId, searchTerm) {
|
2021-07-28 16:15:52 +03:00
|
|
|
changeInviteUser({
|
|
|
|
isOpen: true,
|
|
|
|
roomId,
|
2021-08-08 07:53:26 +03:00
|
|
|
searchTerm,
|
2021-07-28 16:15:52 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
function openSettings() {
|
|
|
|
changeSettings(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
navigation.on(cons.events.navigation.INVITE_LIST_OPENED, openInviteList);
|
2021-08-31 16:13:31 +03:00
|
|
|
navigation.on(cons.events.navigation.PUBLIC_ROOMS_OPENED, openPublicRooms);
|
|
|
|
navigation.on(cons.events.navigation.CREATE_ROOM_OPENED, openCreateRoom);
|
2021-07-28 16:15:52 +03:00
|
|
|
navigation.on(cons.events.navigation.INVITE_USER_OPENED, openInviteUser);
|
|
|
|
navigation.on(cons.events.navigation.SETTINGS_OPENED, openSettings);
|
|
|
|
return () => {
|
|
|
|
navigation.removeListener(cons.events.navigation.INVITE_LIST_OPENED, openInviteList);
|
2021-08-31 16:13:31 +03:00
|
|
|
navigation.removeListener(cons.events.navigation.PUBLIC_ROOMS_OPENED, openPublicRooms);
|
|
|
|
navigation.removeListener(cons.events.navigation.CREATE_ROOM_OPENED, openCreateRoom);
|
2021-07-28 16:15:52 +03:00
|
|
|
navigation.removeListener(cons.events.navigation.INVITE_USER_OPENED, openInviteUser);
|
|
|
|
navigation.removeListener(cons.events.navigation.SETTINGS_OPENED, openSettings);
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<InviteList
|
|
|
|
isOpen={isInviteList}
|
|
|
|
onRequestClose={() => changeInviteList(false)}
|
|
|
|
/>
|
2021-08-31 16:13:31 +03:00
|
|
|
<PublicRooms
|
|
|
|
isOpen={publicRooms.isOpen}
|
|
|
|
searchTerm={publicRooms.searchTerm}
|
|
|
|
onRequestClose={() => changePublicRooms({ isOpen: false, searchTerm: undefined })}
|
2021-07-28 16:15:52 +03:00
|
|
|
/>
|
2021-08-31 16:13:31 +03:00
|
|
|
<CreateRoom
|
|
|
|
isOpen={isCreateRoom}
|
|
|
|
onRequestClose={() => changeCreateRoom(false)}
|
2021-07-28 16:15:52 +03:00
|
|
|
/>
|
|
|
|
<InviteUser
|
|
|
|
isOpen={inviteUser.isOpen}
|
|
|
|
roomId={inviteUser.roomId}
|
2021-08-08 07:53:26 +03:00
|
|
|
searchTerm={inviteUser.searchTerm}
|
2021-07-28 16:15:52 +03:00
|
|
|
onRequestClose={() => changeInviteUser({ isOpen: false, roomId: undefined })}
|
|
|
|
/>
|
|
|
|
<Settings
|
|
|
|
isOpen={settings}
|
|
|
|
onRequestClose={() => changeSettings(false)}
|
|
|
|
/>
|
2022-01-29 10:18:06 +02:00
|
|
|
<SpaceSettings />
|
2021-07-28 16:15:52 +03:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Windows;
|