Skip to content

Commit

Permalink
fixup: variable naming and commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy committed Nov 5, 2024
1 parent a5cd319 commit 404c18b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/compass-generative-ai/src/atlas-ai-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export class AtlasAiService {
}

async ensureAiFeatureAccess({ signal }: { signal?: AbortSignal } = {}) {
// When the ai feature is attempted to be opened we need to make sure
// When the ai feature is attempted to be opened we make sure
// the user is signed into Atlas and opted in.
return getStore().dispatch(signIntoAtlasWithModalPrompt({ signal }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('atlasSignInReducer', function () {
});

expect(store.getState()).to.have.nested.property('state', 'initial');
// void store.dispatch(signIntoAtlasWithModalPrompt()).catch(() => {});
void store.dispatch(atlasServiceSignedIn());
await store.dispatch(signIn());
expect(mockAtlasService.signIn).not.to.have.been.called;
Expand Down
14 changes: 8 additions & 6 deletions packages/compass-generative-ai/src/store/atlas-signin-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import reducer, {
import type { AtlasAuthService } from '@mongodb-js/atlas-service/provider';
import type { ActivateHelpers } from 'hadron-app-registry';

let store: AtlasServiceStore;
let store: CompassGenerativeAIServiceStore;
export function getStore() {
if (!store) {
throw new Error('AtlasAuthPlugin not activated');
throw new Error('CompassGenerativeAIPlugin not activated');
}
return store;
}

export type AtlasAuthPluginServices = {
export type CompassGenerativeAIPluginServices = {
atlasAuthService: AtlasAuthService;
};
export function activatePlugin(
_: Record<string, never>,
services: AtlasAuthPluginServices,
services: CompassGenerativeAIPluginServices,
{ cleanup }: ActivateHelpers
) {
store = configureStore(services);
Expand All @@ -41,12 +41,14 @@ export function activatePlugin(
return { store, deactivate: cleanup };
}

export function configureStore({ atlasAuthService }: AtlasAuthPluginServices) {
export function configureStore({
atlasAuthService,
}: CompassGenerativeAIPluginServices) {
const store = createStore(
reducer,
applyMiddleware(thunk.withExtraArgument({ atlasAuthService }))
);
return store;
}

export type AtlasServiceStore = ReturnType<typeof configureStore>;
export type CompassGenerativeAIServiceStore = ReturnType<typeof configureStore>;

0 comments on commit 404c18b

Please sign in to comment.