Skip to content

Commit

Permalink
Refactor getChatTabBrickRoad
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Feb 1, 2024
1 parent 55242e5 commit f305cc1
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/libs/WorkspacesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,32 +98,19 @@ function getChatTabBrickRoad(policyID?: string): BrickRoad | undefined {

let brickRoad: BrickRoad | undefined;

Object.keys(allReports).forEach((reportID) => {
if (brickRoad === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) {
return;
}

if (policyID && policyID !== allReports?.[reportID]?.policyID) {
return;
}

const policyReport = allReports ? allReports[reportID] : null;
const policyReports = policyID ? Object.values(allReports).filter((report) => report?.policyID === policyID) : Object.values(allReports);

if (!policyReport) {
return;
}
const hasChatTabRBR = policyReports.some((report) => report && getBrickRoadForPolicy(report) === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR);

const workspaceBrickRoad = getBrickRoadForPolicy(policyReport);
if (hasChatTabRBR) {
return CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
}

if (workspaceBrickRoad === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) {
brickRoad = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR;
return;
}
const hasChatTabGBR = policyReports.some((report) => report && getBrickRoadForPolicy(report) === CONST.BRICK_ROAD_INDICATOR_STATUS.INFO);

if (!brickRoad && workspaceBrickRoad) {
brickRoad = workspaceBrickRoad;
}
});
if (hasChatTabGBR) {
return CONST.BRICK_ROAD_INDICATOR_STATUS.INFO;
}

return brickRoad;
}
Expand Down

0 comments on commit f305cc1

Please sign in to comment.