Uh oh!
There was an error while loading. Please reload this page.
Fix challenge reward sort - #11627
Conversation
|
| @@ -350,41 +350,57 @@ export const makeOptimisticChallengeSortComparator = ( | |||
| ChallengeName.PlayCount10000 | |||
There was a problem hiding this comment.
constplayCountOrder=[ChallengeName.PlayCount250,ChallengeName.PlayCount1000,ChallengeName.PlayCount10000]constHIGH_PRIORITY=0constLOW_PRIORITY=1constgetSortKey=(challenge: OptimisticUserChallenge,id: ChallengeRewardID)=>{constclaimablePriority=challenge.claimableAmount>0 ? HIGH_PRIORITY : LOW_PRIORITYconstnewAndNotDisbursedPriority=isNewChallenge(challenge.challenge_id)&&challenge.state!=='disbursed'
? HIGH_PRIORITY
: LOW_PRIORITYconstdisbursedPriority=challenge.state==='disbursed' ? LOW_PRIORITY : HIGH_PRIORITY// Assigns a numeric index for play count challenges (e.g., PlayCount250 = 0, PlayCount1000 = 1).// Non-play-count challenges get -1, ensuring they sort before play count challenges when other priorities are equal.constplayCountIndex=isPlayCountChallenge(id)
? playCountOrder.indexOf(id)
: -1// Returns an array of four numbers representing the sort priorities in order of importance.return[claimablePriority,newAndNotDisbursedPriority,disbursedPriority,playCountIndex]}exportconstmakeOptimisticChallengeSortComparator=(userChallenges: Partial<Record<ChallengeRewardID,OptimisticUserChallenge>>): ((id1: ChallengeRewardID,id2: ChallengeRewardID)=>number)=>{return(id1,id2)=>{constuserChallenge1=userChallenges[id1]constuserChallenge2=userChallenges[id2]if(!userChallenge1||!userChallenge2){return0}constkey1=getSortKey(userChallenge1,id1)constkey2=getSortKey(userChallenge2,id2)for(leti=0;i<key1.length;i++){if(key1[i]<key2[i])return-1if(key1[i]>key2[i])return1}return0}}this is also an option. i think this is a bit easier to digest imo. the array returned in getSortKey key is in priority order. both sort the same
| // Priority 2: New and not disbursed challenges come next | ||
| const isNewAndNotDisbursed = (userChallenge: OptimisticUserChallenge) => | ||
| isNewChallenge(userChallenge.challenge_id) && | ||
| userChallenge.state !== 'disbursed' |
There was a problem hiding this comment.
this might get weird with aggregate challenges. why not use the claimable amount logic like above?
There was a problem hiding this comment.
oh bc those should already be handled. nvm
[dc6bab1]⚠️ Misc reward QA fixes (#11626) Reed [c6ceaf4] Fix challenge reward sort (#11627) Farid Salau [a11bfff] Query core blocks in block confirm endpoint (#11624) Reed [5aa86b1] Fix type errors that slipped through to main (#11623) Andrew Mendelsohn [ddb9503] [C-5832] Typechecking for tan-query selector option (#11603) Andrew Mendelsohn [50ab5c8] [C-5827] Tan-query profile reposts to main (web) (#11609) JD Francis [a804619] Add summary table to tastemaker mobile UI (#11617) Reed [cd0e6c0] [PAY-3998] Tastemaker challenge UI (#11615) Reed [1d074b0] Revert "[C-5833] Avoid spreading queryResults (#11601)" (#11612) Andrew Mendelsohn [154078a] Add count for play count cards (#11610) Farid Salau [b70578a] [C-5833] Avoid spreading queryResults (#11601) Andrew Mendelsohn [9691d33] [PAY-4021] Address bug bash comments for play count milestones (#11606) Farid Salau [448f5db] [C-5795] Tan-query search to main (#11542) JD Francis [f486072] Increase undisbursed challenge req limit to 500 (#11599) Reed [69c4da2] [QA-2011] Fix mobile-web drawer x close icon (#11593) Reed [ec5ca1a] [C-5815] Migrate followers user-list to tan-query (#11546) Dylan Jeffers [8bc0a7f] Use AAO plugin in prod (#11584) Isaac Solo [b231754] Audius Client (Web and Mobile) v1.5.125 (#11582) Dylan Jeffers [e1db903] Update playcount milestones challenge config & add icons (#11577) Farid Salau [3e4099c] [PAY-3935][PAY-3828] Remove remaining references to metadata_multihash in client and discovery (#11567) Randy Schott [7482138] Remove prop in PlayCountMilestoneContent causing type error (#11575) Farid Salau [df654fa] [C-5828] Fix useQueries default loading state (#11569) Dylan Jeffers [e22bac5] Fix unlocked gated content section on web (#11568) Reed [2a0405e] Remove dependency on getCurrentBlock in SDK (#11560) Randy Schott [84eb2f8] [PAY-3979][PAY-3990] Update play count challenge BE and Add the FE (#11521) Farid Salau [b477340] [QA-2008] Fixes styling issues on receive audio modal (#11559) Randy Schott [6550aa3] [QA-2007] Fix deleted page not respecting max page width (#11558) Randy Schott [c4437c8] [PAY-3982] Re-add trending, tier explainers to mobile & update mobile rewards banners (#11523) Reed [35ffe9e] [QA-2004] Fix delete icon popping above edit collection form footer (#11519) Randy Schott [3f631c1] Summary Table for first weekly comment challenge (#11520) Reed [f51f433] [PAY-3994] Prevent -1 fetches in tan query hooks (#11545) Raymond Jacobson
Description
Messed up the sort in #11606, this fixes it
How Has This Been Tested?
npm run web:stagecards should be sorted as listed in the comments in this diff