Skip to content

Commit

Permalink
Refactor getWorkspacesUnreadStatuses and getWorkspacesBrickRoads
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Feb 1, 2024
1 parent 2ff8e8f commit 55242e5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/libs/WorkspacesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,12 @@ function getWorkspacesBrickRoads(): Record<string, BrickRoad> {
}
});

Object.keys(allReports).forEach((reportID) => {
const policyID = allReports?.[reportID]?.policyID ?? CONST.POLICY.EMPTY;
const policyReport = allReports ? allReports[reportID] : null;
if (!policyReport || workspacesBrickRoadsMap[policyID] === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) {
Object.values(allReports).forEach((report) => {
const policyID = report?.policyID ?? CONST.POLICY.EMPTY;
if (!report || workspacesBrickRoadsMap[policyID] === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) {
return;
}
const workspaceBrickRoad = getBrickRoadForPolicy(policyReport);
const workspaceBrickRoad = getBrickRoadForPolicy(report);

if (!workspaceBrickRoad && !!workspacesBrickRoadsMap[policyID]) {
return;
Expand All @@ -190,14 +189,13 @@ function getWorkspacesUnreadStatuses(): Record<string, boolean> {

const workspacesUnreadStatuses: Record<string, boolean> = {};

Object.keys(allReports).forEach((reportID) => {
const policyID = allReports?.[reportID]?.policyID;
const policyReport = allReports ? allReports[reportID] : null;
if (!policyID || (!policyReport && workspacesUnreadStatuses[policyID])) {
Object.values(allReports).forEach((report) => {
const policyID = report?.policyID;
if (!policyID || workspacesUnreadStatuses[policyID]) {
return;
}

workspacesUnreadStatuses[policyID] = ReportUtils.isUnread(policyReport);
workspacesUnreadStatuses[policyID] = ReportUtils.isUnread(report);
});

return workspacesUnreadStatuses;
Expand Down

0 comments on commit 55242e5

Please sign in to comment.