Skip to content

Commit

Permalink
fix: call contracts for on landing company change (deriv-com#17297)
Browse files Browse the repository at this point in the history
  • Loading branch information
henry-deriv authored Oct 24, 2024
1 parent a93b656 commit a059bd1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/trader/src/AppV2/Hooks/useContractsForCompany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ const useContractsForCompany = () => {
const [contract_types_list, setContractTypesList] = React.useState<TContractTypesList | []>([]);

const [trade_types, setTradeTypes] = React.useState<TContractType[]>([]);
const { contract_type, onChange, setContractTypesListV2 } = useTraderStore();
const { contract_type, onChange, setContractTypesListV2, processContractsForV2, symbol } = useTraderStore();
const { client } = useStore();
const { loginid, is_switching, landing_company_shortcode } = client;
const prev_landing_company_shortcode_ref = React.useRef(landing_company_shortcode);

const isQueryEnabled = useCallback(() => {
if (isLoginidDefined(loginid) && !landing_company_shortcode) return false;
Expand Down Expand Up @@ -163,6 +164,18 @@ const useContractsForCompany = () => {

const new_contract_type = getNewContractType(trade_types);
processNewContractType(new_contract_type);

if (landing_company_shortcode !== prev_landing_company_shortcode_ref.current) {
onChange({
target: {
name: 'symbol',
value: symbol,
},
}).then(() => {
processContractsForV2();
prev_landing_company_shortcode_ref.current = landing_company_shortcode;
});
}
}
} catch (err) {
/* eslint-disable no-console */
Expand Down

0 comments on commit a059bd1

Please sign in to comment.