Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longer, more persistant results #178

Merged
merged 3 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions front-end/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions front-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@ebay/nice-modal-react": "^1.2.10",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.1.0",
"@mui/icons-material": "^5.14.1",
"@mui/lab": "^5.0.0-alpha.137",
"@mui/material": "^5.14.1",
Expand Down
19 changes: 17 additions & 2 deletions front-end/src/api/events/display-event.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import { Displays } from '@toa-lib/models';
import { useRecoilCallback } from 'recoil';
import { displayIdAtom } from 'src/stores/recoil';
import {
displayIdAtom,
matchOccurringAtom,
matchOccurringRanksAtom,
matchResultsMatchAtom,
matchResultsRanksAtom
} from 'src/stores/recoil';

export const useDisplayEvent = () => {
return useRecoilCallback(({ set }) => async (id: number) => {
return useRecoilCallback(({ set, snapshot }) => async (id: number) => {
// For match result, we store the currentMatchAtom to matchResultsMatchAtom to avoid the results screen updating when the match is updated.
if (id === Displays.MATCH_RESULTS) {
const match = await snapshot.getPromise(matchOccurringAtom);
set(matchResultsMatchAtom, JSON.parse(JSON.stringify(match)));

const ranks = await snapshot.getPromise(matchOccurringRanksAtom);
set(matchResultsRanksAtom, JSON.parse(JSON.stringify(ranks)));
}
set(displayIdAtom, id);
});
};
51 changes: 40 additions & 11 deletions front-end/src/apps/audience-display/displays/ad-default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useRecoilValue } from 'recoil';
import {
matchOccurringAtom,
matchOccurringRanksAtom,
matchResultsMatchAtom,
matchResultsRanksAtom,
matchStateAtom
} from 'src/stores/recoil';
import { useEvent } from 'src/api/use-event-data';
Expand All @@ -28,7 +30,9 @@ import { useTeamsForEvent } from 'src/api/use-team-data';
*/
export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
const match = useRecoilValue(matchOccurringAtom);
const matchResultsMatch = useRecoilValue(matchResultsMatchAtom);
const ranks = useRecoilValue(matchOccurringRanksAtom);
const matchResultsRanks = useRecoilValue(matchResultsRanksAtom);
const matchState = useRecoilValue(matchStateAtom);
const [searchParams] = useSearchParams();

Expand Down Expand Up @@ -86,7 +90,7 @@ export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
return (
<displays.matchPlayStream
event={event}
match={match}
match={matchResultsMatch ?? match}
ranks={ranks}
teams={teams}
/>
Expand All @@ -95,7 +99,7 @@ export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
return (
<displays.matchResultsStream
event={event}
match={match}
match={matchResultsMatch ?? match}
ranks={ranks}
teams={teams}
/>
Expand All @@ -111,6 +115,25 @@ export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
const showPreviewFull =
layout[0] === LayoutMode.FULL || layout[1] === LayoutMode.FULL;

// show the stream results during the preview
const showStreamResultsDuringPreview =
layout[2] === LayoutMode.STREAM &&
layout[0] === LayoutMode.RESULTS &&
id === Displays.MATCH_PREVIEW;

// show the full results during the preview
const showFullResultsDuringPreview =
layout[2] === LayoutMode.FULL &&
layout[0] === LayoutMode.RESULTS &&
id === Displays.MATCH_PREVIEW;

// force hide the preview if we are showing the results
const forceHidePreview =
showStreamResultsDuringPreview || showFullResultsDuringPreview;

const resultsToUse = !matchResultsMatch ? match : matchResultsMatch;
const ranksToUse = !matchResultsRanks ? ranks : matchResultsRanks;

return (
<>
{/* Displays.BLANK (show nothing) */}
Expand All @@ -120,7 +143,11 @@ export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
{showPreviewFull && (
<AbsolouteLocator top={0} left={0}>
<FadeInOut
in={id === Displays.MATCH_PREVIEW || afterMatchBeforeScore}
in={
// if we are showing the preview full and we are not showing the results
(id === Displays.MATCH_PREVIEW && !forceHidePreview) ||
afterMatchBeforeScore
}
duration={0.5}
>
<displays.matchPreview
Expand All @@ -135,7 +162,7 @@ export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
{layout[0] === LayoutMode.STREAM && (
<AbsolouteLocator bottom={0} left={0}>
<SlideInBottom
in={id === Displays.MATCH_PREVIEW}
in={id === Displays.MATCH_PREVIEW && !forceHidePreview}
duration={1.25}
inDelay={0.75}
>
Expand Down Expand Up @@ -185,27 +212,29 @@ export const AudDisplayDefault: FC<DisplayModeProps> = ({ id }) => {
{/* Displays.MATCH_RESULTS */}
{layout[2] === LayoutMode.FULL && (
<AbsolouteLocator top={0} left={0}>
<FadeInOut in={id === Displays.MATCH_RESULTS}>
<FadeInOut
in={id === Displays.MATCH_RESULTS || showFullResultsDuringPreview}
>
<displays.matchResults
event={event}
match={match}
ranks={ranks}
match={resultsToUse}
ranks={ranksToUse}
teams={teams}
/>
</FadeInOut>
</AbsolouteLocator>
)}
{layout[2] === LayoutMode.STREAM && (
{layout[2] === LayoutMode.STREAM && matchResultsMatch && (
<AbsolouteLocator top={0} left={0}>
<SlideInLeft
in={id === Displays.MATCH_RESULTS}
in={id === Displays.MATCH_RESULTS || showStreamResultsDuringPreview}
duration={1.25}
inDelay={0.75}
>
<displays.matchResultsStream
event={event}
match={match}
ranks={ranks}
match={resultsToUse}
ranks={ranksToUse}
teams={teams}
/>
</SlideInLeft>
Expand Down
4 changes: 4 additions & 0 deletions front-end/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { getFromLocalStorage } from './stores/local-storage';
import { AppContainer } from './App';
import { useCurrentEvent } from './api/use-event-data';
import { CssBaseline } from '@mui/material';
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';

const container = document.getElementById('root');
if (!container) throw new Error('Error while trying to find document root.');
Expand Down
10 changes: 10 additions & 0 deletions front-end/src/stores/recoil/event-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export const matchOccurringAtom = atom<Match<any> | null>({
default: null
});

// this "freezes" the match occuring atom when the display is set to results so it doesn't update anymore
export const matchResultsMatchAtom = atom<Match<any> | null>({
key: 'eventState.matchResultsMatchAtom',
default: null
});
export const matchResultsRanksAtom = atom<Ranking[] | null>({
key: 'eventState.matchResultsRanksAtom',
default: null
});

export const matchOccurringRanksAtom = atom<Ranking[] | null>({
key: 'eventState.matchOccurringRanksAtom',
default: null
Expand Down
3 changes: 2 additions & 1 deletion lib/models/src/base/Audience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ export enum AudienceScreens {
export enum LayoutMode {
OFF = 'o',
STREAM = 's',
FULL = 'f'
FULL = 'f',
RESULTS = 'r'
}
4 changes: 2 additions & 2 deletions lib/models/src/base/MatchTimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const FGC_MATCH_CONFIG: MatchConfiguration = {
transitionTime: 0,
delayTime: 0,
autoTime: 0,
teleTime: 150,
endTime: 30
teleTime: 10,
endTime: 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert this file @Techno11

};

export const FRC_MATCH_CONFIG: MatchConfiguration = {
Expand Down
Loading