(engine: Host, pinned: Backend.Backend)
| 317 | } |
| 318 | |
| 319 | function startPoll(engine: Host, pinned: Backend.Backend) { |
| 320 | const readHeadKey = () => pinned.headKeyOf().catch(() => '') |
| 321 | |
| 322 | if (polled.toplevel === pinned.repository.toplevel) { |
| 323 | return |
| 324 | } |
| 325 | |
| 326 | timers.get('poll')?.cancel() |
| 327 | polled.toplevel = pinned.repository.toplevel |
| 328 | polled.headKey = '' |
| 329 | |
| 330 | timers.set( |
| 331 | 'poll', |
| 332 | engine.every(Limits.HEAD_POLL_MS, () => { |
| 333 | if (!isPaneSeen()) { |
| 334 | return |
| 335 | } |
| 336 | |
| 337 | if (isRefreshQueued && !isRefreshing) { |
| 338 | void endOverdueRest(engine) |
| 339 | } |
| 340 | |
| 341 | void readHeadKey().then(key => { |
| 342 | const hasMoved = polled.headKey !== '' && key !== polled.headKey |
| 343 | |
| 344 | polled.headKey = key |
| 345 | |
| 346 | if (hasMoved) { |
| 347 | scheduleRefresh(engine) |
| 348 | } |
| 349 | }) |
| 350 | }), |
| 351 | ) |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * One read of the diff, covering every change seen before it starts. A call |
no test coverage detected