Skip to content
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
7 changes: 3 additions & 4 deletions src/datascience-ui/interactive-common/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function getDebugState(vms: ICellViewModel[]): DebugState {
return firstNonDesign ? firstNonDesign.runningByLine : DebugState.Design;
}

function createMiddleWare(testMode: boolean): Redux.Middleware<{}, IStore>[] {
function createMiddleWare(testMode: boolean, postOffice: PostOffice): Redux.Middleware<{}, IStore>[] {
// Create the middleware that modifies actions to queue new actions
const queueableActions = createQueueableActionMiddleware();

Expand All @@ -304,8 +304,7 @@ function createMiddleWare(testMode: boolean): Redux.Middleware<{}, IStore>[] {
// Create the test middle ware. It sends messages that are used for testing only
// Or if testing in UI Test.
// tslint:disable-next-line: no-any
const acquireVsCodeApi = (window as any).acquireVsCodeApi as Function;
const isUITest = acquireVsCodeApi && acquireVsCodeApi().handleMessage ? true : false;
const isUITest = postOffice.vscodeApi && (postOffice.vscodeApi as any).handleMessage ? true : false;
const testMiddleware = testMode || isUITest ? createTestMiddleware() : undefined;

// Create the logger if we're not in production mode or we're forcing logging
Expand Down Expand Up @@ -423,7 +422,7 @@ export function createStore<M>(
});

// Create our middleware
const middleware = createMiddleWare(testMode).concat([addMessageDirectionMiddleware]);
const middleware = createMiddleWare(testMode, postOffice).concat([addMessageDirectionMiddleware]);

// Use this reducer and middle ware to create a store
const store = Redux.createStore(rootReducer, Redux.applyMiddleware(...middleware));
Expand Down
2 changes: 1 addition & 1 deletion src/datascience-ui/react-common/postOffice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export declare function acquireVsCodeApi(): IVsCodeApi;
export type PostOfficeMessage = { type: string; payload?: any };
// tslint:disable-next-line: no-unnecessary-class
export class PostOffice implements IDisposable {
public vscodeApi: IVsCodeApi | undefined;
private registered: boolean = false;
private vscodeApi: IVsCodeApi | undefined;
private handlers: IMessageHandler[] = [];
private baseHandler = this.handleMessages.bind(this);
private readonly subject = new Subject<PostOfficeMessage>();
Expand Down