Skip to content

Commit 3fc6ea2

Browse files
committed
Hotfix: Fix vote count in document title on refresh
1 parent 3971f76 commit 3fc6ea2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

client/src/components/Navbar.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ export const Navbar = ({ options }: NavbarProps) => {
2323
const location = useLocation();
2424
const pollId = cookies.get(pollIdCookie);
2525
const [totalVotes, setTotalVotes] = useState(0);
26-
document.title = mcsPollVoting;
26+
27+
if (location.pathname === voteControlsPath) {
28+
document.title = `Votes: ${totalVotes}`;
29+
} else {
30+
document.title = mcsPollVoting;
31+
}
2732

2833
const resultHandler = (res: any) => {
2934
const currentVotes = res.totalVotes;
3035
setTotalVotes(currentVotes);
31-
if (location.pathname === voteControlsPath) {
32-
document.title = `Votes: ${currentVotes}`;
33-
}
3436
};
3537

3638
socket.on("result", resultHandler);

0 commit comments

Comments
 (0)