Skip to content
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

feat: [2/n] cancel all -- notifications #976

Merged

Conversation

aforaleka
Copy link
Contributor

@aforaleka aforaleka commented Aug 30, 2024

image image

add notifications for cancel all orders

  • new type of notification, that shows # of orders canceled out of total
  • when user submits a new batch to cancel all, we just add / replace the batch in the state, so only the latest one is tracked
  • when an order is confirmed cancel either through validator or indexer, we update the tracking so it shows x+1/n canceled in the notification
  • if an order failed cancel (pretty rare), we will show a separate notif for it being canceled with error msg. it will also update the failed order ids in the batch so notif knows to expire when it's done loading

to test:

  • add a ?cancelall=1 flag at the end of url
  • click cancel all on either all markets / filtered market

Copy link

linear bot commented Aug 30, 2024

Copy link

vercel bot commented Aug 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v4-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 4:19pm
v4-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 4:19pm

@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch from bad6440 to 75bfa25 Compare August 30, 2024 17:06
@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch from 75bfa25 to c9e3d9a Compare September 9, 2024 17:34
@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders branch from 943f414 to 1a0b591 Compare September 9, 2024 18:05
Base automatically changed from aleka/ct-1157-fe-support-for-cancel-all-orders to main September 9, 2024 20:44
@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch from c9e3d9a to 183f00f Compare September 10, 2024 15:25
@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch from 183f00f to 239ed7f Compare September 11, 2024 16:27
@aforaleka aforaleka marked this pull request as ready for review September 13, 2024 19:37
@aforaleka aforaleka requested a review from a team as a code owner September 13, 2024 19:37
@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch from 239ed7f to 2916450 Compare September 13, 2024 22:15
@aforaleka aforaleka force-pushed the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch from 2916450 to 42e4994 Compare September 16, 2024 21:12
@@ -680,6 +684,9 @@ export const notificationTypes: NotificationTypeConfig[] = [
const existingOrder = allOrders?.find((order) => order.id === localCancel.orderId);
if (!existingOrder) return;

// skip if this is from a cancel all operation and isn't an error
if (localCancel.isSubmittedThroughCancelAll && !localCancel.errorParams) return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when user clicks cancel all, we won't show a new toast per cancel. we'll just have one notif, and only show a toast for the cancel when there was an error for that specific operation

isSubmittedThroughCancelAll?: boolean;
};

export const CANCEL_ALL_ORDERS_KEY = 'all';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

canceling all orders in all markets, vs. just in the current market

@@ -157,7 +162,7 @@ export const accountSlice = createSlice({
: order
)
: state.localPlaceOrders,
submittedCanceledOrders: hasNewFillUpdates
localCancelOrders: hasNewFillUpdates
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sad it was a typo from before

@@ -111,6 +115,7 @@ const initialState: AccountState = {
historicalPnlPeriod: undefined,
localPlaceOrders: [],
localCancelOrders: [],
localCancelAlls: {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map of market (or 'all') -> cancel all objects

const isOrderCanceledByBackend = (orderId: string) =>
canceledOrderIdsInPayload.includes(orderId) &&
!state.localCancelOrders.map((order) => order.orderId).includes(orderId);
const getNewCanceledOrderIds = (batch: LocalCancelAllData) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when there are new fill updates from indexer, we check for the newly canceled orders, and get the ones that are in the current local cancel all batch

Copy link
Contributor

@moo-onthelawn moo-onthelawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

light UX thought is that it seems really easy to hit "Cancel All" - do we want ot add an intermediate confirmation step (Are you sure you want to cancel all? modal)

action={ButtonAction.Primary}
size={ButtonSize.XSmall}
onClick={onClearOrCancelAll}
isHighlighted={hasCancelableOrders}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm is it intentional that we don't want "Clear All" to also be purple? I sorta like having them as both Purple, otherwise it doesn't seem very obvious that it's clickable
Screenshot 2024-09-17 at 1 05 25 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think mostly to distinguish it from 'cancel all' and same with the faded X for dismiss -- but will sync with product/design for feedback!

notification,
}: NotificationProps & ElementProps) => {
const stringGetter = useStringGetter();
const isCancelForSingleMarket = localCancelAll.key !== CANCEL_ALL_ORDERS_KEY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit,. as a follow up maybe we could add some extra code to detect if all the orders are attributed to a single market, even if the user isn't filtered to it

: order
);
},
cancelAllSubmitted: (
state,
action: PayloadAction<{ marketId?: string; orderIds: string[] }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, can we throw a comment explaining that not passing in a market id globally cancels all orders and passing in one only cancels orders for that market? I have a slight thought that it might also be clearer if we split it into cancelAllSubmitted and cancelAllForMarketSubmitted but I can also see that being a lil verbose

@aforaleka aforaleka merged commit 600cb70 into main Sep 17, 2024
8 checks passed
@aforaleka aforaleka deleted the aleka/ct-1157-fe-support-for-cancel-all-orders-notifications branch September 17, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants