-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40f4acb
commit 1a74b49
Showing
6 changed files
with
93 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FC, Suspense } from 'react'; | ||
import { useRecoilValue } from 'recoil'; | ||
import { SyncDisplayToRecoil } from 'src/components/sync-effects/sync-display-to-recoi'; | ||
import { SyncMatchStateToRecoil } from 'src/components/sync-effects/sync-match-state-to-recoil'; | ||
import { SyncOnPrestart } from 'src/components/sync-effects/sync-on-prestart'; | ||
import ChromaLayout from 'src/layouts/ChromaLayout'; | ||
import { currentEventKeyAtom, displayIdAtom } from 'src/stores/NewRecoil'; | ||
import Displays from './displays'; | ||
|
||
export const AudienceDisplay: FC = () => { | ||
const eventKey = useRecoilValue(currentEventKeyAtom); | ||
const displayId = useRecoilValue(displayIdAtom); | ||
return ( | ||
<Suspense | ||
fallback={ | ||
<div | ||
style={{ | ||
position: 'absolute', | ||
height: '100vh', | ||
width: '100vw', | ||
backgroundColor: 'rgba(0,0,0,0)' | ||
}} | ||
/> | ||
} | ||
> | ||
<ChromaLayout> | ||
<SyncMatchStateToRecoil /> | ||
<SyncOnPrestart /> | ||
<SyncDisplayToRecoil /> | ||
<Displays id={displayId} eventKey={eventKey} /> | ||
</ChromaLayout> | ||
</Suspense> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { FC } from 'react'; | ||
|
||
interface Props { | ||
id: number; | ||
eventKey: string | null | undefined; | ||
mode?: string; | ||
} | ||
|
||
const Displays: FC<Props> = () => { | ||
return null; | ||
}; | ||
|
||
export default Displays; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { AudienceDisplay } from './audience-display'; | ||
|
||
export { AudienceDisplay }; |
23 changes: 23 additions & 0 deletions
23
front-end/src/components/sync-effects/sync-display-to-recoi.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FC, useEffect } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
import { useSocket } from 'src/api/use-socket'; | ||
import { displayIdAtom } from 'src/stores/NewRecoil'; | ||
|
||
export const SyncDisplayToRecoil: FC = () => { | ||
const setDisplay = useSetRecoilState(displayIdAtom); | ||
const [socket, connected] = useSocket(); | ||
|
||
useEffect(() => { | ||
if (connected) { | ||
socket?.on('DISPLAY', setDisplay); | ||
} | ||
}, [connected]); | ||
|
||
useEffect(() => { | ||
return () => { | ||
socket?.removeListener('DISPLAY', setDisplay); | ||
}; | ||
}, []); | ||
|
||
return null; | ||
}; |