Adding window visibility check, removing generic sleep.
This commit is contained in:
parent
caf445cae7
commit
ee7f54bb0d
2 changed files with 19 additions and 17 deletions
|
@ -410,29 +410,31 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
|
|
||||||
fetchUnreads() {
|
fetchUnreads() {
|
||||||
poll(async () => {
|
poll(async () => {
|
||||||
const auth = myAuth();
|
if (window.document.visibilityState !== "hidden") {
|
||||||
if (auth) {
|
const auth = myAuth();
|
||||||
this.setState({
|
if (auth) {
|
||||||
unreadInboxCountRes: await HttpService.client.getUnreadCount({
|
|
||||||
auth,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.moderatesSomething) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadReportCountRes: await HttpService.client.getReportCount({
|
unreadInboxCountRes: await HttpService.client.getUnreadCount({
|
||||||
auth,
|
auth,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (amAdmin()) {
|
if (this.moderatesSomething) {
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadApplicationCountRes:
|
unreadReportCountRes: await HttpService.client.getReportCount({
|
||||||
await HttpService.client.getUnreadRegistrationApplicationCount({
|
|
||||||
auth,
|
auth,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amAdmin()) {
|
||||||
|
this.setState({
|
||||||
|
unreadApplicationCountRes:
|
||||||
|
await HttpService.client.getUnreadRegistrationApplicationCount({
|
||||||
|
auth,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, updateUnreadCountsInterval);
|
}, updateUnreadCountsInterval);
|
||||||
|
|
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue