Skip to content

Commit 6a9732c

Browse files
committed
Improve file name format and remove data polling
1 parent 90a6688 commit 6a9732c

File tree

1 file changed

+3
-17
lines changed
  • src/components/IdeLauncher/IncidentDetails

1 file changed

+3
-17
lines changed

src/components/IdeLauncher/IncidentDetails/index.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { formatISO } from "date-fns";
12
import { useCallback, useEffect, useState } from "react";
23
import { useParams } from "react-router";
34
import { useGetIncidentQuery } from "../../../redux/services/digma";
@@ -21,12 +22,9 @@ import { trackingEvents } from "../tracking";
2122
import type { AddChatContextFileResult } from "../types";
2223
import { addChatContextFile } from "./addChatContextFile";
2324

24-
const REFRESH_INTERVAL = 10 * 1000; // in milliseconds
25-
2625
export const IncidentDetails = () => {
2726
const params = useParams();
2827
const incidentId = params.id;
29-
const [isIncidentNotFound, setIsIncidentNotFound] = useState(false);
3028
const [selectItems, setSelectItems] = useState<SelectItem[]>();
3129
const [isIdeProjectScanningInProgress, setIsIdeProjectScanningInProgress] =
3230
useState(false);
@@ -44,7 +42,6 @@ export const IncidentDetails = () => {
4442
} = useGetIncidentQuery(
4543
{ id: incidentId ?? "" },
4644
{
47-
pollingInterval: isIncidentNotFound ? 0 : REFRESH_INTERVAL,
4845
skip: !incidentId
4946
}
5047
);
@@ -58,7 +55,7 @@ export const IncidentDetails = () => {
5855
setAddChatContextFileResult(undefined);
5956
setAddingChatContextFileInProgress(true);
6057
const result = await addChatContextFile(port, {
61-
name: `incident-${incidentId}.json`,
58+
name: `incident-${incidentId}-${formatISO(new Date(), { format: "basic" })}.json`,
6259
content: JSON.stringify(incidentData, null, 2)
6360
});
6461
sendTrackingEvent(trackingEvents.IDE_CHAT_CONTEXT_FILE_RESULT_RECEIVED, {
@@ -159,16 +156,6 @@ export const IncidentDetails = () => {
159156
void initialScan();
160157
}, [tryToScanRunningIdeProjects]);
161158

162-
useEffect(() => {
163-
setIsIncidentNotFound(false);
164-
}, [incidentId]);
165-
166-
useEffect(() => {
167-
if (error && "status" in error && error.status === 404) {
168-
setIsIncidentNotFound(true);
169-
}
170-
}, [error]);
171-
172159
const renderContent = () => {
173160
if (!incidentId) {
174161
return (
@@ -278,8 +265,7 @@ export const IncidentDetails = () => {
278265
);
279266
}
280267

281-
// TODO: remove equal check when we have only one IDE project
282-
if (selectItems.length >= 1) {
268+
if (selectItems.length > 1) {
283269
return (
284270
<>
285271
<TextContainer>

0 commit comments

Comments
 (0)