-
Notifications
You must be signed in to change notification settings - Fork 133
[PE-6065] Deprecate audius-query account.ts #12038
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18ee962
Add missing account hooks
DejayJD 1110150
wip
DejayJD 4807240
finish moving over hooks
DejayJD f0e2d3c
Merge branch 'main' of github.com:AudiusProject/audius-protocol into …
DejayJD ee18e4a
remove file
DejayJD 99b1ca1
rework to use isFetching and 0 staleTime
DejayJD 9407495
Remove unnecessary casts
DejayJD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/common/src/api/tan-query/users/account/useApproveManagedAccount.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { Id } from '@audius/sdk' | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
|
|
||
| import { useAudiusQueryContext } from '~/audius-query' | ||
| import { User, UserMetadata } from '~/models' | ||
|
|
||
| import { getManagedAccountsQueryKey } from './useManagedAccounts' | ||
|
|
||
| type ApproveManagedAccountPayload = { | ||
| userId: number | ||
| grantorUser: UserMetadata | User | ||
| } | ||
|
|
||
| export const useApproveManagedAccount = () => { | ||
| const { audiusSdk } = useAudiusQueryContext() | ||
| const queryClient = useQueryClient() | ||
| return useMutation({ | ||
| mutationFn: async (payload: ApproveManagedAccountPayload) => { | ||
| const { grantorUser, userId } = payload | ||
| const grantorUserId = grantorUser.user_id | ||
| const encodedUserId = Id.parse(userId) | ||
| const encodedGrantorUserId = Id.parse(grantorUserId) | ||
| const sdk = await audiusSdk() | ||
| await sdk.grants.approveGrant({ | ||
| userId: encodedUserId, | ||
| grantorUserId: encodedGrantorUserId | ||
| }) | ||
| return payload | ||
| }, | ||
| onSuccess: (data) => { | ||
| queryClient.invalidateQueries({ | ||
| queryKey: getManagedAccountsQueryKey(data.userId) | ||
| }) | ||
| } | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 like this as an alternative to optimistic updates, just wondering if the grant will have been indexed fast enough for this to work?
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.
Was working fine in my testing, but I'm open to exploring more if you think theres potential for issues here out in the wild.
I assume this SDK call waits for confirmation before returning, but what you're saying is there's still potential for indexing being behind still, right?
Maybe an optimistic update is the way to go then? 🤔
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 it's testing fine on stage, maybe we can leave it unless we see issues. I believe you're correct that SDK will confirm it.
Alternatively we write something that polls until it finds the new manager?
Optimistic usually seems to get us in more trouble than it's worth :-D