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/components/Insights/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export interface Method {
name: string;
}

export interface WrappedInsightData {
insightsViewMode: string;
data: InsightsData;
}

export interface InsightsData {
insights: GenericCodeObjectInsight[];
totalCount: number;
Expand Down
13 changes: 10 additions & 3 deletions src/components/Insights/useInsightsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { InsightFilterType, ViewMode } from "./InsightsCatalog/types";
import { actions as issuesActions } from "./Issues/actions";
import { GetIssuesDataListQuery } from "./Issues/types";
import { actions } from "./actions";
import { InsightsData, InsightViewType } from "./types";
import { InsightViewType, WrappedInsightData } from "./types";

interface UseInsightsDataProps {
areFiltersRehydrated: boolean;
Expand Down Expand Up @@ -235,8 +235,15 @@ export const useInsightsData = ({
timeStamp: number,
error: DigmaMessageError | undefined
) => {
const insightsData = data as WrappedInsightData;

//Do not handle the response message if the view mode has been already changed
if (insightViewType !== insightsData.insightsViewMode) {
return;
}

if (!error) {
setData(data as InsightsData);
setData(insightsData.data);
}
setIsLoading(false);
setLastSetDataTimeStamp(timeStamp);
Expand All @@ -258,7 +265,7 @@ export const useInsightsData = ({
handleInsightsData
);
};
}, [setData, setIsLoading]);
}, [setData, setIsLoading, insightViewType]);

useEffect(() => {
if (previousLastSetDataTimeStamp !== lastSetDataTimeStamp) {
Expand Down