Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

let currentUserAccountID = -1;
let currentEmail = '';
Onyx.connect({

Check warning on line 69 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID;
Expand All @@ -74,13 +74,6 @@
},
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
});

type DomainOnyxUpdate =
| OnyxUpdate<`${typeof ONYXKEYS.COLLECTION.DOMAIN}${string}`>
| OnyxUpdate<`${typeof ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${string}`>
Expand Down Expand Up @@ -1056,6 +1049,7 @@
*/
function setContactMethodAsDefault(
currentUserPersonalDetails: OnyxEntry<OnyxPersonalDetails>,
policies: OnyxCollection<Policy>,
newDefaultContactMethod: string,
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'],
backTo?: string,
Expand Down Expand Up @@ -1156,7 +1150,7 @@
},
];

for (const policy of Object.values(allPolicies ?? {})) {
for (const policy of Object.values(policies ?? {})) {
if (!policy) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) {
const [myDomainSecurityGroups, myDomainSecurityGroupsResult] = useOnyx(ONYXKEYS.MY_DOMAIN_SECURITY_GROUPS);
const [securityGroups, securityGroupsResult] = useOnyx(ONYXKEYS.COLLECTION.SECURITY_GROUP);
const [isLoadingReportData = true, isLoadingReportDataResult] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [isValidateCodeFormVisible, setIsValidateCodeFormVisible] = useState(true);
const {isActingAsDelegate} = useDelegateNoAccessState();
const {showDelegateNoAccessModal} = useDelegateNoAccessActions();
Expand Down Expand Up @@ -93,8 +94,8 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) {
* Attempt to set this contact method as user's "Default contact method"
*/
const setAsDefault = useCallback(() => {
setContactMethodAsDefault(currentUserPersonalDetails, contactMethod, formatPhoneNumber, backTo);
}, [currentUserPersonalDetails, contactMethod, formatPhoneNumber, backTo]);
setContactMethodAsDefault(currentUserPersonalDetails, allPolicies, contactMethod, formatPhoneNumber, backTo);
}, [currentUserPersonalDetails, allPolicies, contactMethod, formatPhoneNumber, backTo]);

/**
* Determines whether the user's primary login switching is restricted
Expand Down
Loading