Commit 4c4b783 1 parent 2c1c946 commit 4c4b783 Copy full SHA for 4c4b783
File tree 1 file changed +18
-3
lines changed
src/main/services/additional-content
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -242,7 +242,9 @@ export class LocalPlaylistsManagerService {
242
242
...localBPList ,
243
243
duration : 0 ,
244
244
nbMaps : localBPList . songs ?. length ?? 0 ,
245
- id : localBPList . customData ?. syncURL ? tryExtractPlaylistId ( localBPList . customData . syncURL ) : undefined
245
+ id : localBPList . customData ?. syncURL ? tryExtractPlaylistId ( localBPList . customData . syncURL ) : undefined ,
246
+ minNps : Infinity ,
247
+ maxNps : - Infinity ,
246
248
}
247
249
248
250
const mappers = new Set < number > ( ) ;
@@ -254,12 +256,25 @@ export class LocalPlaylistsManagerService {
254
256
255
257
bpListDetails . duration += songDetails ?. duration ? + songDetails . duration : 0 ;
256
258
mappers . add ( songDetails . uploader ?. id ) ;
257
- bpListDetails . minNps = Math . min ( bpListDetails ?. minNps ?? 0 , Math . min ( ...songDetails . difficulties ?. map ( d => d ?. nps || 0 ) ?? [ 0 ] ) ) ;
258
- bpListDetails . maxNps = Math . max ( bpListDetails ?. maxNps ?? 0 , Math . max ( ...songDetails . difficulties ?. map ( d => d ?. nps || 0 ) ?? [ 0 ] ) ) ;
259
+
260
+ const mapNps = songDetails . difficulties ?. map ( d => d ?. nps ) . filter ( nps => typeof nps === "number" && ! Number . isNaN ( nps ) ) ;
261
+
262
+ if ( mapNps ?. length ) {
263
+ bpListDetails . minNps = Math . min ( bpListDetails . minNps , ...mapNps ) ;
264
+ bpListDetails . maxNps = Math . max ( bpListDetails . maxNps , ...mapNps ) ;
265
+ }
259
266
260
267
song . songDetails = songDetails ;
261
268
}
262
269
270
+ if ( ! Number . isFinite ( bpListDetails . minNps ) ) {
271
+ bpListDetails . minNps = 0 ;
272
+ }
273
+
274
+ if ( ! Number . isFinite ( bpListDetails . maxNps ) ) {
275
+ bpListDetails . maxNps = 0 ;
276
+ }
277
+
263
278
bpListDetails . nbMappers = mappers . size ;
264
279
265
280
return bpListDetails ;
You can’t perform that action at this time.
0 commit comments