Skip to content

Commit

Permalink
Minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlihou committed Jul 15, 2023
1 parent 7ca2657 commit f92f39c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion database.rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"cg": {
"$eventKey": {
".read": "root.child('seasons/'+$season+'/events/'+$eventKey).child('startMs').val() < now && root.child('seasons/'+$season+'/events/'+$eventKey).child('endMs').val() > now",
".write": "auth.token.admin === true || data.child('users/'+auth.uid).val() === true"
".write": "auth.token.admin === true || root.child('seasons/'+$season+'/cgUsers/'+$eventKey+'/'+auth.uid).val() === true"
}
},
"avatars": {
Expand Down
5 changes: 1 addition & 4 deletions src/Overlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ export default function Overlay() {
useEffect(() => {
const cgRef = ref(getDatabase(), `/seasons/${season}/cg/${token}`);
onValue(cgRef, (snap) => {
setCgConfig(snap.val() as CGConfig);
setCgConfig(snap.val() as CGConfig ?? {});
});

// Leave it to the streaming app or CG config to dictate the page background
document.body.style.background = 'rgba(0, 0, 0, 0) !important';
}, []);

// useEffect(() => {
Expand Down
44 changes: 27 additions & 17 deletions src/components/Manage/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from 'firebase/database';
import AppContext from '@/AppContext';
import { CGConfig } from '@/types';
import ErrorMessage from '../ErrorMessage';

const OptionsPage = styled.div`
font-size: 18px;
Expand Down Expand Up @@ -97,6 +98,8 @@ const Options = () => {
const email = useMemo(() => getAuth().currentUser?.email, undefined);
const { event, season, token } = useContext(AppContext);

const [error, setError] = useState<string>('');

const [pageBg, setPageBg] = useState<string>('#f0f');

const [syncColors, setSyncColors] = useState<boolean>(true);
Expand Down Expand Up @@ -148,24 +151,30 @@ const Options = () => {
}, [syncColors, brandingBg, brandingTextColor]);

const take = async () => {
if (cgConfigDbRef.current === undefined) {
console.error('DB Reference not defined');
return;
setError('');
try {
if (cgConfigDbRef.current === undefined) {
throw new Error('DB Reference not defined');
}
await set(cgConfigDbRef.current, {
pageBg: pageBg ?? null,
showBranding: showBranding ?? null,
showTicker: showTicker ?? null,
brandingBg: brandingBg ?? null,
brandingTextColor: brandingTextColor ?? null,
tickerBg: tickerBg ?? null,
tickerTextColor: tickerTextColor ?? null,
brandingImage: brandingImage ?? null,
brandingText: brandingText ?? null,
showLowerThird: showLowerThird ?? null,
lowerThirdTitle: lowerThirdTitle ?? null,
lowerThirdSubtitle: lowerThirdSubtitle ?? null,
} as CGConfig);
} catch (e) {
if (e instanceof Error) {
setError(e.message);
}
}
await set(cgConfigDbRef.current, {
pageBg: pageBg ?? null,
showBranding: showBranding ?? null,
showTicker: showTicker ?? null,
brandingBg: brandingBg ?? null,
brandingTextColor: brandingTextColor ?? null,
tickerBg: tickerBg ?? null,
tickerTextColor: tickerTextColor ?? null,
brandingImage: brandingImage ?? null,
brandingText: brandingText ?? null,
showLowerThird: showLowerThird ?? null,
lowerThirdTitle: lowerThirdTitle ?? null,
lowerThirdSubtitle: lowerThirdSubtitle ?? null,
} as CGConfig);
};

const onClickLogout = async () => {
Expand All @@ -190,6 +199,7 @@ const Options = () => {
</div>
</div>
</StyledHeader>
{error && <ErrorMessage type="error">{error}</ErrorMessage>}
<main>
<OptionsBox>
<h2>Colors</h2>
Expand Down

0 comments on commit f92f39c

Please sign in to comment.