mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
Merge pull request #677 from prymitive/requestAnimationFrame
fix(ui): delay initial fetch until browser is idle
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user