-
Notifications
You must be signed in to change notification settings - Fork 43
Add library albums and playlists audius-query hook + migrate collection reformat util; bump SDK PAY-1679 #3864
Conversation
packages/common/src/api/library.ts
Outdated
options: { | ||
kind: Kind.COLLECTIONS, | ||
schemaKey: 'collections', | ||
idListArgKey: 'playlist_id' |
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.
We don't need idListArgKey
here.
idListArgKey
is only useful if you have a hook argument containing the ids of the results you expect. It allows cache hits before making the initial fetch.
Example:
fetchCollections(collection_ids: ID[])
idArgKey: 'collection_ids'
usage: useFetchCollections({ collection_ids: ['123', '456'] })
now if collections 123 and 456 are found in the cache, we skip the initial fetch.
However, for this case, we don't know upfront what ids we are going to need, so we always have to fetch and construct the entity list based on the response.
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.
ahh thanks for the clarification
packages/common/src/api/library.ts
Outdated
getLibraryAlbums: { | ||
fetch: async ( | ||
args: GetLibraryAlbumsArgs, | ||
{ audiusSdk, audiusBackend } | ||
) => { | ||
const { | ||
userId, | ||
offset, | ||
limit, | ||
query = '', | ||
sortMethod = 'added_date', | ||
sortDirection = 'desc' | ||
} = args | ||
const sdk = await audiusSdk() | ||
const { data, signature } = | ||
await audiusBackend.signDiscoveryNodeRequest() | ||
const { data: rawAlbums = [] } = | ||
await sdk.full.users.getUserLibraryAlbums({ | ||
id: encodeHashId(userId), | ||
userId: encodeHashId(userId), | ||
offset, | ||
limit, | ||
query, | ||
sortMethod, | ||
sortDirection, | ||
type: 'all', | ||
encodedDataMessage: data, | ||
encodedDataSignature: signature | ||
}) | ||
const albumsMetadata = rawAlbums | ||
.map((r: APIActivityV2) => makeActivity(r)) | ||
.filter(removeNullable) as UserCollectionMetadata[] | ||
const albums = albumsMetadata.map((am) => | ||
reformatCollection({ | ||
collection: am, | ||
audiusBackendInstance: audiusBackend, | ||
omitUser: false | ||
}) | ||
) | ||
return albums | ||
}, |
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.
Amazing! This is a perfect use of audius-query 🎉
packages/common/src/api/library.ts
Outdated
.map((r: APIActivityV2) => makeActivity(r)) | ||
.filter(removeNullable) as UserCollectionMetadata[] | ||
const albums = albumsMetadata.map((am) => | ||
reformatCollection({ |
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. This makes me wonder if it's worth building in the reformatters for each entity type? Do you know if we always want to transform the data for every instance of collection?
@@ -40,7 +40,7 @@ export function* processAndCacheCollections( | |||
yield addTracksFromCollections(collections) | |||
|
|||
let reformattedCollections = collections.map((c) => | |||
reformat(c, audiusBackendInstance) | |||
reformatCollection({ collection: c, audiusBackendInstance }) |
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.
Oh wait, I see. The cache already does this, so by calling addEntries
in audius-query, we already do it.
Have you tried it without calling this in the endpoint's fetch implementation? It probably helps the types match up, but I think the data should still be there if you don't. We should be saving the results to cache which internally calls reformatCollection
then selecting the cache data as the return from the hook.
packages/common/src/api/library.ts
Outdated
} = args | ||
const sdk = await audiusSdk() | ||
const { data, signature } = | ||
await audiusBackend.signDiscoveryNodeRequest() |
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.
Do we have to do this for every sdk request? Feels like it should be baked into the sdk :-/
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.
yeah 100%, it's a follow up task for the SDK https://linear.app/audius/issue/C-2928/enable-sdk-reads-for-authenticated-routes-[follow-on]
41bdcd1
to
23bb67b
Compare
It looks like there may be some changes to native mobile code, which requires triggering a full app release. Please follow the instructions here: https://www.notion.so/audiusproject/When-to-bump-app-version-2644a8f772364a4d91f44abcba44ce0b?pvs=4. cc @nicoback2 @sliptype |
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
It looks like there may be some changes to native mobile code, which requires triggering a full app release. Please follow the instructions here: https://www.notion.so/audiusproject/When-to-bump-app-version-2644a8f772364a4d91f44abcba44ce0b?pvs=4. cc @nicoback2 @sliptype |
Preview this change https://demo.audius.co/nkang--albums-query |
* origin/main: Add lint check for console.log and remove some bad ones (#3930) [C-2968] Fix private collection action buttons (#3937) Fix canonical url consistency (#3938) [C-2689] Add upload confirmation modal (#3934) [C-2966] Make sure that collection description limits are set to 1000 (#3935) Move sitemap hostname back to audius.co (#3931) Client uses cids in requests to CN for images (#3882) Add library albums and playlists audius-query hook + migrate collection reformat util; bump SDK PAY-1679 (#3864) [C-2982] Fix seo based on ahref recommendations (#3929) Migrate withdraw USDC saga to web common (#3928) USDC Withdrawal saga scaffolding (#3926) Fix useAllPaginated query C-2980 (#3924) Fix infinite scrolling cards C-2979 (#3923) [PAY-1632] Clean up and improve performance of music confetti (#3921) Revert "Update twitter icon on mobile (#3880)" (#3925)
[b39cb5d] [PAY-1733] Remove Gated Prompt Modal (#3948) Marcus Pasell [a522294] [PAY-1748][PAY-1731][PAY-1729][PAY-1730] DMs link fixes (#3946) Marcus Pasell [adea357] quick linting fix (#3945) Kyle Shanks [a0ff27c] Add embed cloudflare deployment and CI (#3940) Raymond Jacobson [337f80f] [PAY-1727] USDC Withdrawals saga pt. 1 (#3932) Reed [5bf820c] [C-2956] Add new Access & Sale modal to legacy upload form (#3900) Andrew Mendelsohn [5258675] [C-2986] Upload flow qa round 1 (#3941) Kyle Shanks [dd30c09] Use does_current_user_subscribe API field (#3943) Michelle Brier [778a518] [C-2987] Add UserGeneratedText (#3942) Dylan Jeffers [bb9e0cf] Update pull_request_template.md (#3939) Raymond Jacobson [930dd1a] [C-2977] Fix collection page seo (#3936) Dylan Jeffers [1e50b85] Update README.md (#3911) sabrina-kiam [687fd28] Add lint check for console.log and remove some bad ones (#3930) Raymond Jacobson [9f67e7b] [C-2968] Fix private collection action buttons (#3937) Dylan Jeffers [7ab7a38] Fix canonical url consistency (#3938) Dylan Jeffers [b1fbef8] [C-2689] Add upload confirmation modal (#3934) Kyle Shanks [eb41fd3] [C-2966] Make sure that collection description limits are set to 1000 (#3935) Kyle Shanks [6258484] Move sitemap hostname back to audius.co (#3931) Raymond Jacobson [1e0c335] Client uses cids in requests to CN for images (#3882) Michelle Brier [7974acc] Add library albums and playlists audius-query hook + migrate collection reformat util; bump SDK PAY-1679 (#3864) nicoback2 [7cba35b] [C-2982] Fix seo based on ahref recommendations (#3929) Dylan Jeffers [05744b3] Migrate withdraw USDC saga to web common (#3928) Reed [5d01710] USDC Withdrawal saga scaffolding (#3926) Reed [4e0c480] Fix useAllPaginated query C-2980 (#3924) nicoback2 [21eb35c] Fix infinite scrolling cards C-2979 (#3923) nicoback2 [0025261] [PAY-1632] Clean up and improve performance of music confetti (#3921) Raymond Jacobson [7ed2248] Revert "Update twitter icon on mobile (#3880)" (#3925) Reed [1091934] [PAY-1742] Remove useMetaMask on invalid account (#3920) Raymond Jacobson [6e303b1] [PAY-1741] Add routes for transactional pages (#3916) Randy Schott [74cdb3c] Remove ontouchstart from index.html (#3919) Raymond Jacobson [1a0332c] Improve lighthouse score (#3918) Raymond Jacobson [a63896f] [PAY-1706] Merge modalsWithState with modals in common store (#3908) Marcus Pasell [6a08944] [C-2976] Fix profile-page seo (#3912) Dylan Jeffers [2381d46] Fix account details css (#3917) Raymond Jacobson [8c24bdd] Fix mobile share of playlist permalink (#3913) sabrina-kiam [1e376fe] [C-2911] Update new select page of the upload flow (#3910) Kyle Shanks [bc0226f] Fix stripe modal opening behavior (#3914) Raymond Jacobson [a3219c3] [C-2975] Fix stale local data (#3915) Dylan Jeffers [748fdfd] PAY-1724 Add color specialGreen on mobile (#3909) Reed [5c59fe5] [PAY-1628] Navigate to track after purchase (#3904) Randy Schott
Description
-Add audius-query hook for getting library albums
-Migrate collection
reformat
util to common-Some type + ResponseAdapter fixing
Note this is going into main, not feature branch. See feature branch PR here:
#3865
BEFORE MERGING:
-Merge protocol PR
-Generate SDK
-Bump SDK ver in client
Dragons
Is there anything the reviewer should be on the lookout for? Are there any dangerous changes?
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide repro instructions & any configuration.
How will this change be monitored?
For features that are critical or could fail silently please describe the monitoring/alerting being added.
Feature Flags
Are all new features properly feature flagged? Describe added feature flags.