diff --git a/frontend/src/Client.tsx b/frontend/src/Client.tsx index 7ed56d9..c68d052 100644 --- a/frontend/src/Client.tsx +++ b/frontend/src/Client.tsx @@ -11,7 +11,14 @@ const Client = () => { const [buttonMap, setButtonMap] = useState(defaultButtonMap); const updateButtonEvent = (button: ButtonType, state: "down" | "up") => - () => setButtonMap((m) => ({ ...m, [button]: (state === "down") })); + () => setButtonMap((m) => { + const newMap = { ...m, [button]: (state === "down") }; + if (mapToBitvector(newMap).reduce((a,b) => a+b, 0) > 1) { + return m; + } else { + return newMap; + } + }); // Send data to server diff --git a/frontend/src/TVMode.tsx b/frontend/src/TVMode.tsx index a4f0637..dfc4f4e 100644 --- a/frontend/src/TVMode.tsx +++ b/frontend/src/TVMode.tsx @@ -27,7 +27,7 @@ const TVMode = () => { }, []) const totalCount = useMemo(() => buttonTypeList.reduce((acc, v) => (state?.votes?.[v] ?? 0) + acc, 0), [state]); - const voteList = useMemo(() => buttonTypeList.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number]).sort((a, b) => a[1] < b[1] ? -1 : 1), [state]); + const voteList = useMemo(() => buttonTypeList.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number]).sort((a, b) => b[1] - a[1]), [state]); return
{state === undefined ? @@ -40,7 +40,11 @@ const TVMode = () => {
{voteList.flatMap(([b, numVotes], index) => numVotes === 0 - ? [] + ? [ +
+ {b} +
+ ] : [
{b} {Math.round(numVotes / totalCount * 100) + "%"}