Skip to content

Commit

Permalink
Refactor workspace switcher and PolicyMembersUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Feb 1, 2024
1 parent 45ec867 commit efea383
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function subscribeToReportCommentPushNotifications() {

Log.info('[PushNotification] onSelected() - Navigation is ready. Navigating...', false, {reportID, reportActionID});
if (!reportBelongsToWorkspace) {
Navigation.navigateWithSwitchPolicyID({policyID: undefined, route: ROUTES.HOME});
Navigation.navigateWithSwitchPolicyID({route: ROUTES.HOME});
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(String(reportID)));
} catch (error) {
Expand Down
8 changes: 3 additions & 5 deletions src/libs/PolicyMembersUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PolicyMembers} from '@src/types/onyx';
import {getCurrentUserAccountID} from './actions/Report';
import {getPolicyMembersByIdWithoutCurrentUser} from './PolicyUtils';

let policyMembers: OnyxCollection<PolicyMembers>;
Onyx.connect({
Expand All @@ -17,11 +18,8 @@ function getPolicyMemberAccountIDs(policyID?: string) {
}

const currentUserAccountID = getCurrentUserAccountID();
return policyMembers
? Object.keys(policyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${policyID}`] ?? {})
.map((policyMemberAccountID) => Number(policyMemberAccountID))
.filter((policyMemberAccountID) => policyMemberAccountID !== currentUserAccountID)
: [];

return getPolicyMembersByIdWithoutCurrentUser(policyMembers, policyID, currentUserAccountID);
}

export default getPolicyMemberAccountIDs;
2 changes: 1 addition & 1 deletion src/pages/WorkspaceSwitcherPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function WorkspaceSwitcherPage({policies}) {
</View>
<View>
<OptionRow
option={{...option, brickRoadIndicator: !activeWorkspaceID ? undefined : option.brickRoadIndicator}}
option={option}
onSelectRow={selectPolicy}
showTitleTooltip={false}
shouldShowSubscript={false}
Expand Down

0 comments on commit efea383

Please sign in to comment.