Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ jobs:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v4
- name: Install packages (webapp)
run: pnpm ci
run: pnpm install --frozen-lockfile
- name: Install packages (functions)
run: npm ci --prefix=functions

- name: Build
run: npm run build --prefix=functions

- name: Lint
run: npx eslint 'functions/src/**/*.{js,ts}' -c functions/.eslintrc.js
# - name: Lint
# run: npx eslint 'functions/src/**/*.{js,ts}' -c functions/.eslintrc.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules
functions/*-debug.log
size-plugin.json
.idea
dist
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "vite build",
"serve": "sirv build --port 8080 --cors --single",
"dev": "vite",
"lint": "eslint './src/**/*.{js,jsx,ts,tsx}' './functions/src/**/*.{js,ts}'",
"lint": "eslint './src/**/*.{js,jsx,ts,tsx}'",
"lint-win": "eslint src/ functions/"
},
"dependencies": {
Expand All @@ -19,6 +19,7 @@
"firebase": "^12.9.0",
"js-cookie": "^3.0.1",
"milligram": "^1.4.1",
"motion": "^12.38.0",
"preact": "^10.3.1",
"preact-iso": "^2.3.1",
"preact-router": "^4.1.0",
Expand Down
62 changes: 62 additions & 0 deletions pnpm-lock.yaml

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

9 changes: 5 additions & 4 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import AuthenticatedRoute from '../AuthenticatedRoute';

// TODO: Figure out why the event details sometimes aren't getting sent over to SignalR

const ErrorFallback = ({ error }: { error: unknown }) => {
function ErrorFallback({ error }: { error: unknown }) {
// Reload after a while to try a recovery
useEffect(() => {
const timeout = setTimeout(() => {
Expand Down Expand Up @@ -84,9 +84,9 @@ const ErrorFallback = ({ error }: { error: unknown }) => {
<small style={{ fontSize: '.5em', display: 'block', paddingTop: '1em' }}>{(error as Error)?.message}</small>
</div>
);
};
}

const App = () => {
function App() {
const [db, setDb] = useState<Database>();
const hub = useRef<HubConnection | undefined>(undefined);
const [connection, setConnection] = useState<{
Expand Down Expand Up @@ -348,6 +348,7 @@ const App = () => {
<div id="preact_root" className={styles.app}>
{identifyTO !== null && <div className={styles.identify}>{hub.current?.connectionId}</div>}
<ErrorBoundary FallbackComponent={ErrorFallback}>
{/* eslint-disable-next-line react/jsx-no-constructed-context-values */}
<AppContext.Provider value={appContext ?? {}}>
{connection?.connectionStatus === 'offline' && (
<div className={styles.warningBar}>
Expand All @@ -361,6 +362,6 @@ const App = () => {
</ErrorBoundary>
</div>
);
};
}

export default App;
8 changes: 4 additions & 4 deletions src/components/AuthenticatedRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment } from 'preact';
import { h } from 'preact';
import { Route, RouteProps, route } from 'preact-router';
import { useEffect, useState } from 'preact/hooks';
import { getAuth, onAuthStateChanged } from 'firebase/auth';
Expand All @@ -9,8 +9,8 @@ export default function AuthenticatedRoute<T>(props: RouteProps<T> & Partial<T>)
(async () => {
const auth = getAuth();
await Promise.race([
new Promise((res) => setTimeout(res, 5000)),
new Promise<void>((res) => onAuthStateChanged(auth, () => res())),
new Promise((res) => { setTimeout(res, 5000); }),
new Promise<void>((res) => { onAuthStateChanged(auth, () => res()); }),
]);
const isLoggedIn = auth.currentUser != null;
if (!isLoggedIn) {
Expand All @@ -21,7 +21,7 @@ export default function AuthenticatedRoute<T>(props: RouteProps<T> & Partial<T>)
}, []);

// not logged in, render nothing:
if (!loggedIn) return <></>;
if (!loggedIn) return null;

// eslint-disable-next-line react/jsx-props-no-spreading
return <Route {...props} />;
Expand Down
41 changes: 24 additions & 17 deletions src/components/Automated/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { h, Fragment, ComponentChildren } from 'preact';
import { useContext } from 'preact/hooks';

import { Event } from '@shared/DbTypes';
import AppContext from '@/AppContext';
import MenuBar from '../MenuBar';
import AppErrorMessage, { ErrorMessageType } from '../ErrorMessage';
Expand All @@ -14,29 +15,35 @@ type AutomatedProps = {
}
};

const Automated = (props: AutomatedProps) => {
const { event, season } = useContext(AppContext);
const { matches: { playoff, qual } } = props;

const ErrorMessage = ({ children, type }: {
children: ComponentChildren,
type?: ErrorMessageType,
}) => (
function ErrorMessage({
children, type, event, season,
}: {
children: ComponentChildren,
type?: ErrorMessageType,
event: Event | undefined,
season: number | undefined
}) {
return (
<>
<MenuBar event={event} season={season} alwaysShow />
<div>
<AppErrorMessage type={type}>{ children }</AppErrorMessage>
</div>
</>
);
}

ErrorMessage.defaultProps = {
type: 'info',
};

ErrorMessage.defaultProps = {
type: 'info',
};
function Automated(props: AutomatedProps) {
const { event, season } = useContext(AppContext);
const { matches: { playoff, qual } } = props;

if (!playoff || !qual) {
return (
<ErrorMessage>
<ErrorMessage event={event} season={season}>
You&apos;re missing some configuration info... Try going
{' '}
{' '}
Expand All @@ -54,7 +61,7 @@ const Automated = (props: AutomatedProps) => {
const routeToUse = Routes.find((r) => r.url === qual && r.usedIn.includes('qual'));
if (!routeToUse) {
return (
<ErrorMessage>
<ErrorMessage event={event} season={season}>
Double check your configuration, something isn&apos;t right here...
</ErrorMessage>
);
Expand All @@ -67,7 +74,7 @@ const Automated = (props: AutomatedProps) => {
const routeToUse = Routes.find((r) => r.url === playoff && r.usedIn.includes('playoff'));
if (!routeToUse) {
return (
<ErrorMessage>
<ErrorMessage event={event} season={season}>
Double check your configuration, something isn&apos;t right here...
</ErrorMessage>
);
Expand All @@ -76,17 +83,17 @@ const Automated = (props: AutomatedProps) => {
}
case 'EventOver':
return (
<ErrorMessage type="arrow">
<ErrorMessage type="arrow" event={event} season={season}>
The event has ended. See you next time!
</ErrorMessage>
);
default:
return (
<ErrorMessage>
<ErrorMessage event={event} season={season}>
Hmm... I&apos;m not sure what the event is up to right now...
</ErrorMessage>
);
}
};
}

export default Automated;
6 changes: 3 additions & 3 deletions src/components/Embeddable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h } from 'preact';
import { h, JSX } from 'preact';
import {
useContext, useEffect, useRef, useState,
} from 'preact/hooks';
Expand All @@ -21,7 +21,7 @@ type EmbeddableProps = {
routeParams: EmbeddableRouteParams,
};

const Embeddable = (props: EmbeddableProps) => {
function Embeddable(props: EmbeddableProps) {
const { routeParams: { iframeUrl: iframeUrlFn } } = props;
const appContext = useContext(AppContext);
const [iframeUrl, setIframeUrl] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -65,6 +65,6 @@ const Embeddable = (props: EmbeddableProps) => {
{ content }
</div>
);
};
}

export default Embeddable;
4 changes: 2 additions & 2 deletions src/components/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ErrorMessageProps = {
type?: ErrorMessageType,
};

const ErrorMessage = (props: ErrorMessageProps) => {
function ErrorMessage(props: ErrorMessageProps) {
const { children } = props;
let { type } = props;
if (type === undefined) type = 'info';
Expand All @@ -22,7 +22,7 @@ const ErrorMessage = (props: ErrorMessageProps) => {
{ children }
</div>
);
};
}

ErrorMessage.defaultProps = {
type: 'info',
Expand Down
5 changes: 4 additions & 1 deletion src/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { h } from 'preact';
import { Link as RouterLink } from 'preact-router';

// eslint-disable-next-line react/jsx-props-no-spreading
const Link = (props: any) => (<RouterLink {...props} />);
function Link(props: any) {
// eslint-disable-next-line react/jsx-props-no-spreading
return (<RouterLink {...props} />);
}

export default Link;
4 changes: 2 additions & 2 deletions src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const StyledBadCode = styled.div`
/**
* Form displayed to the user when they do not already have an event token.
*/
const LoginForm = ({ onLogin }: LoginFormProps) => {
function LoginForm({ onLogin }: LoginFormProps) {
const appContext = useContext(AppContext);
const [eventToken, setEventToken] = useState('');
const [badToken, setBadToken] = useState(false);
Expand Down Expand Up @@ -101,6 +101,6 @@ const LoginForm = ({ onLogin }: LoginFormProps) => {
</Disclaimer>
</div>
);
};
}

export default LoginForm;
4 changes: 2 additions & 2 deletions src/components/Manage/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const Note = styled.span`
}
`;

const Options = () => {
function Options() {
const email = useMemo(() => getAuth().currentUser?.email, undefined);
const { event, season, token } = useContext(AppContext);

Expand Down Expand Up @@ -328,6 +328,6 @@ const Options = () => {
</footer>
</OptionsPage>
);
};
}

export default Options;
6 changes: 3 additions & 3 deletions src/components/Manage/SavedLowerThirds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ const Container = styled.div`
}
`;

const SavedLowerThirds = ({
function SavedLowerThirds({
lowerThirdTitle, lowerThirdSubtitle, cgConfigRef, onLoad,
}: SavedLowerThirdsProps) => {
}: SavedLowerThirdsProps) {
const savedRef = useMemo(() => (cgConfigRef.current ? child(cgConfigRef.current, 'lowerThirds') : undefined), [cgConfigRef.current]);
const [saved, setSaved] = useState<{ [_: string]: SavedLowerThirdRecord }>({});

Expand Down Expand Up @@ -163,6 +163,6 @@ const SavedLowerThirds = ({
</table>
</Container>
);
};
}

export default SavedLowerThirds;
Loading
Loading