@@ -29,7 +29,7 @@ const ENDPOINTS = {
2929 VOTES_V1 : ( ids ) => `/v1/games/votes?universeIds=${ ids } ` ,
3030 GAMES_V1 : ( ids ) => `/v1/games?universeIds=${ ids } ` ,
3131
32- GAME_LINK : ( placeId ) => `https://www.roblox.com/games/${ placeId } `
32+ GAME_LINK : ( placeId ) => `https://www.roblox.com/games/${ placeId } /unnamed` // adding an extra parameter after placeid adds support for btroblox's copy placeid context menu item
3333} ;
3434
3535const Api = {
@@ -162,7 +162,10 @@ const Api = {
162162 }
163163
164164 if ( playerRes ?. data ) {
165- playerRes . data . forEach ( item => state . players . set ( item . id , item . playing || 0 ) ) ;
165+ playerRes . data . forEach ( item => {
166+ state . players . set ( item . id , item . playing || 0 ) ;
167+ state . updated . set ( item . id , item . updated || 0 ) ;
168+ } ) ;
166169 }
167170
168171 const newThumbnails = await fetchThumbnailsBatch ( batch , 'GameIcon' , '256x256' ) ;
@@ -277,7 +280,7 @@ const UI = {
277280class HiddenGamesManager {
278281 constructor ( allGames ) {
279282 this . allGames = allGames ;
280- this . cache = { likes : new Map ( ) , players : new Map ( ) , thumbnails : new Map ( ) } ;
283+ this . cache = { likes : new Map ( ) , players : new Map ( ) , updated : new Map ( ) , thumbnails : new Map ( ) } ;
281284 this . filters = { sort : 'default' , order : 'desc' } ;
282285 this . processedGames = [ ] ;
283286 this . visibleCount = 0 ;
@@ -339,15 +342,17 @@ class HiddenGamesManager {
339342 this . elements . list . appendChild ( createShimmerGrid ( 12 , { width : '150px' , height : '240px' } ) ) ;
340343 this . visibleCount = 0 ;
341344
342- if ( [ 'like-ratio' , 'likes' , 'dislikes' , 'players' ] . includes ( this . filters . sort ) ) {
345+ if ( [ 'default' , ' like-ratio', 'likes' , 'dislikes' , 'players' ] . includes ( this . filters . sort ) ) {
343346 await Api . enrichGameData ( this . allGames , this . cache ) ;
344347 }
345348
346349 const { sort, order } = this . filters ;
347350 const orderMultiplier = order === 'desc' ? - 1 : 1 ;
348351 let sorted = [ ...this . allGames ] ;
349-
350- if ( sort === 'like-ratio' ) {
352+
353+ if ( sort === 'default' ) {
354+ sorted . sort ( ( a , b ) => ( new Date ( this . cache . updated . get ( a . id ) || 0 ) - new Date ( this . cache . updated . get ( b . id ) || 0 ) ) * orderMultiplier ) ;
355+ } else if ( sort === 'like-ratio' ) {
351356 sorted . sort ( ( a , b ) => ( ( this . cache . likes . get ( a . id ) ?. ratio || 0 ) - ( this . cache . likes . get ( b . id ) ?. ratio || 0 ) ) * orderMultiplier ) ;
352357 } else if ( sort === "likes" ) {
353358 sorted . sort ( ( a , b ) => ( ( this . cache . likes . get ( a . id ) ?. upVotes || 0 ) - ( this . cache . likes . get ( b . id ) ?. upVotes || 0 ) ) * orderMultiplier ) ;
0 commit comments