Poll for branch information only in active window
Problem to solve
If the user opens multiple extension windows, all of those windows are going to be polling pipeline information (each 30s) and open MR and closing issue (each 60s) for the current branch. This could result in increased load on the API and issues like #211 (closed)
Proposal
The polling should only happen when the extension window is focused
. Same way as the native git
extension polls for remote branch changes.
We should also start to poll immediately after the window comes into focus (window.onDidChangeWindowState
).
Further details
- https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/ec80a6f81d5d9b5b402dcf8ad50f5ad45c21800b/src/status_bar.js#L121
- https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/ec80a6f81d5d9b5b402dcf8ad50f5ad45c21800b/src/status_bar.js#L184
Links / references
I assume the official git
extension implementation to be somewhere here https://github.com/microsoft/vscode/blob/master/extensions/git/src/statusbar.ts
The official VS Code extension API offers a WindowState
which allows us to find out whether the window is focused or not.