-
Notifications
You must be signed in to change notification settings - Fork 3
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(#385): portfolio positions #386
feat(#385): portfolio positions #386
Conversation
/** Helper function that allows breaking early when using stream responses */ | ||
async function* limitAsync<T>( | ||
iterable: AsyncIterable<T>, | ||
limit: number, | ||
offset: number, | ||
): AsyncIterable<T> { |
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 function replaces basic Array.fromAsync
and breaks early if the limit is reached, thus reducing calculations
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.
Nice
import { bech32mPositionId } from '@penumbra-zone/bech32m/plpid'; | ||
import { queryClient } from '@/shared/const/queryClient'; | ||
import { AddressIndex } from '@penumbra-zone/protobuf/penumbra/core/keys/v1/keys_pb'; | ||
|
||
const BASE_LIMIT = 20; |
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.
if you want to play with the infinite scroll, reduce this limit
export const getDisplayPositions = ({ | ||
positions, | ||
getMetadataByAssetId, | ||
asset1Filter, | ||
asset2Filter, | ||
stateFilter, | ||
}: GetDisplayPositionsArgs): DisplayPosition[] => { |
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.
refactored the arguments of this function – now it accepts filters. By default, returns all positions
</div> | ||
|
||
{(isLoading ? loadingArr : sortedPositions).map((position, index) => ( | ||
<Fragment key={`${position.idString}${index}`}> |
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.
Nitpick: You don't need to do this btw, keys only have to be unique for each loop. So index
is enough here incase we have multiple positions with the same idString
.
Closes #385
In this PR:
usePathMetadata
hook to get base and quote assets and later filter positions based on this. Also, it relied on thepositionsStore
that was difficult to scale and reuse in different pages. During this refactoring, I split the store into independent functions and moved them to the newentities
folder based on feature-sliced conventions.Table
UI component toTableCell
, and from table to grids – it allowed simpler multi-order positions rendering