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/limit UI upgrade 12 #5300

Merged
merged 2 commits into from
Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ export function useOrdersTableList(
): OrdersTableList {
const setIsOrderUnfillable = useSetIsOrderUnfillable()

// First, group and sort all orders
const allSortedOrders = useMemo(() => {
return groupOrdersTable(allOrders).sort(ordersSorter)
}, [allOrders])

// Then, categorize orders into their respective lists
return useMemo(() => {
const { pending, history, unfillable, signing, all } = allSortedOrders.reduce(
(acc, item) => {
Expand Down Expand Up @@ -96,6 +98,7 @@ export function useOrdersTableList(
},
)

// Return sliced lists to respect ORDERS_LIMIT
return {
pending: pending.slice(0, ORDERS_LIMIT),
history: history.slice(0, ORDERS_LIMIT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,23 @@ export function OrdersTableWidget({
const { currentTabId, currentPageNumber } = useMemo(() => {
const params = parseOrdersTableUrl(location.search)

// If we're on a tab that becomes empty (signing or unfillable),
// default to the all orders tab
if (
(params.tabId === 'signing' && !ordersList.signing.length) ||
(params.tabId === 'unfillable' && !ordersList.unfillable.length)
) {
return {
currentTabId: ALL_ORDERS_TAB.id,
currentPageNumber: params.pageNumber || 1,
}
}

return {
currentTabId: params.tabId || ALL_ORDERS_TAB.id,
currentPageNumber: params.pageNumber || 1,
}
}, [location.search])
}, [location.search, ordersList.signing.length, ordersList.unfillable.length])

const orders = useMemo(() => {
return getOrdersListByIndex(ordersList, currentTabId)
Expand Down
Loading