Skip to content

Commit

Permalink
Await PreferenceService to be ready
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Richter <[email protected]>
  • Loading branch information
mvtec-richter committed Feb 25, 2025
1 parent 0d684d4 commit a3c8d4d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ai-core/src/browser/ai-activation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************
import { inject, injectable } from '@theia/core/shared/inversify';
import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
import { Emitter, MaybePromise, Event, } from '@theia/core';
import { Emitter, Event } from '@theia/core';
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
import { PREFERENCE_NAME_ENABLE_AI } from './ai-core-preferences';

Expand Down Expand Up @@ -44,7 +44,8 @@ export class AIActivationService implements FrontendApplicationContribution {
return this.isAiEnabledKey.get() ?? false;
}

initialize(): MaybePromise<void> {
async initialize(): Promise<void> {
await this.preferenceService.ready;
const value = this.preferenceService.get<boolean>(ENABLE_AI_CONTEXT_KEY);
this.isAiEnabledKey = this.contextKeyService.createKey(ENABLE_AI_CONTEXT_KEY, value);
this.preferenceService.onPreferenceChanged(e => {
Expand Down

0 comments on commit a3c8d4d

Please sign in to comment.