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() {
|
||||
poll(async () => {
|
||||
const auth = myAuth();
|
||||
if (auth) {
|
||||
this.setState({
|
||||
unreadInboxCountRes: await HttpService.client.getUnreadCount({
|
||||
auth,
|
||||
}),
|
||||
});
|
||||
|
||||
if (this.moderatesSomething) {
|
||||
if (window.document.visibilityState !== "hidden") {
|
||||
const auth = myAuth();
|
||||
if (auth) {
|
||||
this.setState({
|
||||
unreadReportCountRes: await HttpService.client.getReportCount({
|
||||
unreadInboxCountRes: await HttpService.client.getUnreadCount({
|
||||
auth,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
if (amAdmin()) {
|
||||
this.setState({
|
||||
unreadApplicationCountRes:
|
||||
await HttpService.client.getUnreadRegistrationApplicationCount({
|
||||
if (this.moderatesSomething) {
|
||||
this.setState({
|
||||
unreadReportCountRes: await HttpService.client.getReportCount({
|
||||
auth,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (amAdmin()) {
|
||||
this.setState({
|
||||
unreadApplicationCountRes:
|
||||
await HttpService.client.getUnreadRegistrationApplicationCount({
|
||||
auth,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue