Skip to content

Commit

Permalink
likhith/track js reading loginid of undefined (binary-com#6452)
Browse files Browse the repository at this point in the history
* fix: added a fallback case if virtual account is not available

* fix: added fallback to missing objects containing loginid

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>
  • Loading branch information
likhith-deriv and carolsachdeva committed Sep 21, 2022
1 parent df36349 commit 5b8451e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ const AccountSwitcher = props => {
}, [getMaxAccountsDisplayed]);

React.useEffect(() => {
const vrtc_loginid = props.account_list.find(account => account.is_virtual).loginid;

getExchangeRate(props.accounts[vrtc_loginid].currency, props.obj_total_balance.currency).then(res =>
setExchangedRate(res)
);
// eslint-disable-next-line react-hooks/exhaustive-deps
const vrtc_loginid = props.account_list.find(account => account.is_virtual)?.loginid;
if (vrtc_loginid) {
getExchangeRate(props.accounts[vrtc_loginid].currency, props.obj_total_balance.currency).then(res =>
setExchangedRate(res)
);
}
}, []);

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ChooseCurrency = ({
const doSwitch = async value => {
const target_account = account_list.filter(account => account.title === value);
const loginid = target_account.map(x => x.loginid)[0];
await switchAccount(loginid);
if (loginid) await switchAccount(loginid);
};

const onSubmit = async obj => {
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p/src/utils/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class ExtendedOrderDetails {
}

get is_my_ad() {
return this.order_details.advertiser_details.loginid === this.loginid;
return this.order_details?.advertiser_details?.loginid === this.loginid;
}

get is_inactive_order() {
Expand Down

0 comments on commit 5b8451e

Please sign in to comment.