Adding window visibility check, removing generic sleep.

This commit is contained in:
Dessalines 2023-06-14 20:06:50 -04:00
parent caf445cae7
commit ee7f54bb0d
2 changed files with 19 additions and 17 deletions

View file

@ -410,6 +410,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
fetchUnreads() { fetchUnreads() {
poll(async () => { poll(async () => {
if (window.document.visibilityState !== "hidden") {
const auth = myAuth(); const auth = myAuth();
if (auth) { if (auth) {
this.setState({ this.setState({
@ -435,6 +436,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
}); });
} }
} }
}
}, updateUnreadCountsInterval); }, updateUnreadCountsInterval);
} }

View file

@ -1492,7 +1492,7 @@ export function newVote(voteType: VoteType, myVote?: number): number {
} }
} }
function sleep<T>(millis: number): Promise<T> { function sleep(millis: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, millis)); return new Promise(resolve => setTimeout(resolve, millis));
} }