Skip to content

Commit

Permalink
Merge pull request #1028 from digma-ai/fix/insights-selection
Browse files Browse the repository at this point in the history
Fix insights selection
  • Loading branch information
opoliarush committed Sep 3, 2024
2 parents 0204b9b + 07929e7 commit d385420
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
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

0 comments on commit d385420

Please sign in to comment.