Merge pull request #677 from prymitive/requestAnimationFrame

fix(ui): delay initial fetch until browser is idle
This commit is contained in:
Łukasz Mierzwa
2019-05-04 23:33:29 +01:00
committed by GitHub
2 changed files with 5 additions and 1 deletions

View File

@@ -54,7 +54,8 @@ const Fetcher = observer(
};
componentDidMount() {
this.fetchIfIdle();
// start first fetch once the browser is done doing busy loading
window.requestAnimationFrame(this.fetchIfIdle);
this.timer = setInterval(this.timerTick, 1000);
}

View File

@@ -29,9 +29,12 @@ beforeEach(() => {
settingsStore = new Settings();
settingsStore.fetchConfig.config.interval = 30;
jest.spyOn(window, "requestAnimationFrame").mockImplementation(cb => cb());
});
afterEach(() => {
window.requestAnimationFrame.mockRestore();
jest.clearAllTimers();
jest.clearAllMocks();
jest.restoreAllMocks();