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
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,11 @@ export enum EmbedEvent {
* @hidden
*/
APP_INIT = 'appInit',
/**
* Internal event to clear the cached info
* @hidden
*/
CLEAR_INFO_CACHE = 'clearInfoCache',
/**
* Emitted when a user clicks **Show Liveboard details** on a Liveboard
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
Expand Down
12 changes: 12 additions & 0 deletions src/utils/processData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,16 @@ describe('Unit test for process data', () => {

mockHandleExitPresentMode.mockReset();
});

test('should handle ClearInfoCache', () => {
const mockResetCachedPreauthInfo = jest.spyOn(sessionInfoService, 'resetCachedPreauthInfo').mockImplementation(() => {});
const mockResetCachedSessionInfo = jest.spyOn(sessionInfoService, 'resetCachedSessionInfo').mockImplementation(() => {});
const processedData = {
type: EmbedEvent.CLEAR_INFO_CACHE,
data: {},
};
processDataInstance.processEventData(EmbedEvent.CLEAR_INFO_CACHE, processedData, thoughtSpotHost, null);
expect(mockResetCachedPreauthInfo).toHaveBeenCalled();
expect(mockResetCachedSessionInfo).toHaveBeenCalled();
});
});
10 changes: 10 additions & 0 deletions src/utils/processData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { resetCachedAuthToken } from '../authToken';
import { ERROR_MESSAGE } from '../errors';
import { logger } from '../utils/logger';
import { handleExitPresentMode } from '../utils';
import { resetCachedPreauthInfo, resetCachedSessionInfo } from './sessionInfoService';

/**
* Process the ExitPresentMode event and handle default fullscreen exit
Expand All @@ -26,6 +27,13 @@ function processExitPresentMode(e: any) {
}
}

/**
* Clears the cached preauth and session info.
*/
function processClearInfoCache() {
resetCachedPreauthInfo();
resetCachedSessionInfo();
}
/**
*
* @param e
Expand Down Expand Up @@ -153,6 +161,8 @@ export function processEventData(
return processAuthLogout(e, containerEl);
case EmbedEvent.ExitPresentMode:
return processExitPresentMode(e);
case EmbedEvent.CLEAR_INFO_CACHE:
return processClearInfoCache();
default:
}
return e;
Expand Down
Loading