Skip to content

Commit

Permalink
perf: Improve polling the team feature config [WPB-8734] (#17274) (#1…
Browse files Browse the repository at this point in the history
…7366)

Co-authored-by: Thomas Belin <thomasbelin4@gmail.com>
  • Loading branch information
PatrykBuniX and atomrc committed May 6, 2024
1 parent 0a013a1 commit 5c13b03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/script/team/TeamRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,17 @@ export class TeamRepository extends TypedEventEmitter<Events> {
}

private readonly scheduleTeamRefresh = (): void => {
window.setInterval(async () => {
const updateTeam = async () => {
try {
await this.getTeam();
await this.updateFeatureConfig();
} catch (error) {
this.logger.error(error);
}
}, TIME_IN_MILLIS.SECOND * 30);
};
// We want to poll the latest team data every time the app is focused and every day
window.addEventListener('focus', updateTeam);
window.setInterval(updateTeam, TIME_IN_MILLIS.DAY);
};

private async getInitialTeamMembers(teamId: string): Promise<TeamMemberEntity[]> {
Expand Down
5 changes: 5 additions & 0 deletions src/script/util/DebugUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ export class DebugUtil {
});
}

// Used by QA to trigger a focus event on the app (in order to trigger the update of the team feature-config)
simulateAppToForeground() {
window.dispatchEvent(new FocusEvent('focus'));
}

setE2EICertificateTtl(ttl: number) {
E2EIHandler.getInstance().certificateTtl = ttl;
}
Expand Down

0 comments on commit 5c13b03

Please sign in to comment.