Skip to content

Commit

Permalink
Completed report receiving updates from ongoing analysis (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
itayox authored Aug 14, 2023
1 parent 39674fa commit 09dde4f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ _Can be run using `npm run codetotal:beta`_
- Add a button in report toolbar to show code for snippet & file analysis
- Add a report progress bar
- Optimize new analysis dialog, drawer and linters list components' renders
- Fix completed report receiving updates from ongoing analysis
- Back-End
- Bug fix: SBOM packages not showing up in report page. Async parsing of packages information in SBOM module
- Retry calls to pypi or npm in case first attempts are failing
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/report/actions/clear-report-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ReportStore } from "../stores/fe-report-store";

export const clearReport = () => {
const { unsubscribe, reset } = ReportStore.getState();
// unsubscribe from updates
unsubscribe && unsubscribe();

// reset state
reset();
};
3 changes: 0 additions & 3 deletions packages/app/src/report/actions/init-report-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import { subscribeToReportProgress } from "./subscribe-report-action";

export const initReport = async (requestId: string) => {
try {
// reset report store
ReportStore.getState().reset();

// fetch report
const res = await axios.get(`${ApiUrl}/report/${requestId}`);

Expand Down
3 changes: 0 additions & 3 deletions packages/app/src/report/actions/subscribe-report-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { subscribe } from "../utils/ws-client";
let unsubscribe: () => void;

export const subscribeToReportProgress = (requestId: string) => {
// unsubscribe from previous connection
unsubscribe && unsubscribe();

// clear previous error
ReportStore.setState({ wsError: undefined });

Expand Down
5 changes: 5 additions & 0 deletions packages/app/src/report/components/ReportPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC, useEffect } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { AnalysisErrorDialog } from "../../common/AnalysisErrorDialog";
import { clearReport } from "../actions/clear-report-actions";
import { initReport } from "../actions/init-report-action";
import { LinterDrawer } from "./drawer/LinterDrawer";
import { CodeDialog } from "./header/CodeDialog";
Expand All @@ -24,6 +25,10 @@ const ReportPage: FC = () => {
})();
}, [requestId, navigate]);

useEffect(() => {
return clearReport;
});

return (
<div style={{ paddingBlockEnd: 60 }}>
<ReportHeader ready />
Expand Down

0 comments on commit 09dde4f

Please sign in to comment.