Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

INT-2163 Sync the codemod registry every 15min #831

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/engineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class EngineService {
this.__codemodEngineRustExecutableUri =
message.codemodEngineRustExecutableUri;

await this.__syncRegistry();
await this.syncRegistry();

await this.__fetchCodemods();
await this.fetchPrivateCodemods();
Expand All @@ -248,7 +248,7 @@ export class EngineService {
return this.__codemodEngineNodeExecutableUri !== null;
}

private async __syncRegistry(): Promise<void> {
public async syncRegistry(): Promise<void> {
if (this.__codemodEngineNodeExecutableUri === null) {
throw new Error('The engines are not bootstrapped.');
}
Expand Down
14 changes: 14 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ export async function activate(context: vscode.ExtensionContext) {
mainViewProvider,
);

vscode.window.onDidChangeWindowState((event) => {
let syncRegistryIntervalId;
if (event.focused) {
// Interval in milliseconds (15 minutes)
const interval = 15 * 60 * 1000;

// Start the interval
syncRegistryIntervalId = setInterval(async () => {
await engineService.syncRegistry();
}, interval);
} else {
clearInterval(syncRegistryIntervalId);
}
});
// this is only used by the intuita panel's webview
context.subscriptions.push(
vscode.commands.registerCommand('intuita.redirect', (arg0) => {
Expand Down
Loading