New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Side orders from modals & refactoring #903
Conversation
onemicky
commented
Apr 8, 2024
•
edited
edited
- To see the specific tasks where the Asana app for GitHub is being used, see below:
- https://app.asana.com/0/0/1206545911703990
Deploying gmx-interface with Cloudflare Pages
|
d5f05b5
to
506b667
Compare
ae8858b
to
334f2b7
Compare
✅ Deploy Preview for vigilant-albattani-df38ec ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for superb-tarsier-e2aa29 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
5231ad5
to
ec54c99
Compare
|
||
function onCancelOrderClick(key: string): void { | ||
if (!signer) return; | ||
cancelOrdersTxn(chainId, signer, subaccount, { | ||
orderKeys: [key], | ||
setPendingTxns: p.setPendingTxns, | ||
isLastSubaccountAction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember it was needed for some subacc notification, isn't it needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i can see, now we don't use this param inside the function
|
||
if (existingPosition || !entriesInfo) return; | ||
if (!entriesInfo || !entriesInfo.entries.some((e) => e.txnType !== "cancel")) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be slower but much more readable entriesInfo.entries.every((e) => e.txnType === "cancel")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, thanks
|
||
function handleAddEntry() { | ||
addEntry(); | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestAnimationFrame?
|
||
return ( | ||
<div className="SidecarEntries-wrapper" ref={containerRef}> | ||
{displayableEntries?.map((entry) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's introduce <SidecarEntry key={..} entry={..} />
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yap, good suggestion to improve
|
||
<NumberInput | ||
value={entry.price.input} | ||
onValueChange={(e) => updateEntry(entry.id, "price", e.target.value)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can memoize it in SidecarEntry
component
@@ -97,7 +92,6 @@ export function OrderList(p: Props) { | |||
cancelOrdersTxn(chainId, signer, subaccount, { | |||
orderKeys: [key], | |||
setPendingTxns: p.setPendingTxns, | |||
isLastSubaccountAction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question, probably with same reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
answered on the first note
if (pendingOrder.txnType === "cancel") { | ||
return Boolean(orderStatus?.cancelledTxnHash); | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw mustNeverExist(pendingOrder.txnType)
|
||
function findMatchedOrderStatus(orderList: OrderStatus[], orderData: PendingOrderData) { | ||
return orderList.find((status) => { | ||
const isPendingOrderMatch = status.data && getPendingOrderKey(orderData) === getPendingOrderKey(status.data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a biggie but you can do getPendingOrderKey(orderData)
outside of a loop
: priceError | ||
: inputPrice.lt(triggerPrice) | ||
? t`Price below Limit Price.` | ||
: priceError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these conditions looks very repetitive but don't have a strong idea what to do with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it's a tricky place, hope it's a bit more readable now
}, [effect]); | ||
} | ||
|
||
export default useEffectOnce; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this hook seems like a workaround, are you sure we need to re-use it somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem forced me to create this helper was that i'm unable to set an initial state on a component mount when i use a centralized state & selectors. I agree that it's not a best solution. Ideally, we should maintain state independently of whether the component is mounted or not. But at the moment it makes code a bit more readable. I'll have no problem removing it when it will be no longer needed
@@ -333,7 +334,7 @@ export function OrdersStatusNotificiation({ | |||
if (pendingOrder.txnType === "cancel") { | |||
return Boolean(orderStatus?.cancelledTxnHash); | |||
} | |||
return false; | |||
throw mustNeverExist(pendingOrder.txnType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think throw is redundant because mustNeverExist already throws inside of it