3939import org .jackhuang .hmcl .ui .SVG ;
4040import org .jackhuang .hmcl .ui .construct .*;
4141import org .jackhuang .hmcl .ui .decorator .DecoratorPage ;
42- import org .jackhuang .hmcl .util .Lang ;
4342import org .jackhuang .hmcl .util .Pair ;
4443import org .jackhuang .hmcl .util .StringUtils ;
4544import org .jackhuang .hmcl .util .TaskCancellationAction ;
@@ -351,8 +350,7 @@ private static final class ModItem extends StackPane {
351350 pane .getChildren ().add (descPane );
352351 }
353352
354- RipplerContainer container = new RipplerContainer (pane );
355- getChildren ().setAll (container );
353+ getChildren ().setAll (new RipplerContainer (pane ));
356354
357355 // Workaround for https://github.com/HMCL-dev/HMCL/issues/2129
358356 this .setMinHeight (50 );
@@ -370,13 +368,11 @@ public ModDetail(RemoteMod.Version targetVersion, RemoteModRepository repository
370368
371369 VBox box = new VBox (8 );
372370 box .setPadding (new Insets (8 ));
373- ModItem modItem = new ModItem (targetVersion , source );
374- modItem .setMouseTransparent (true ); // Item is displayed for info, clicking shouldn't open the dialog again
375- box .getChildren ().setAll (modItem );
371+ box .getChildren ().setAll (new ModItem (targetVersion , source ));
376372
377373 SpinnerPane spinnerPane = new SpinnerPane ();
378374 ScrollPane scrollPane = new ScrollPane ();
379- ComponentList changelogComponent = new ComponentList (Lang :: immutableListOf );
375+ ComponentList changelogComponent = new ComponentList (null );
380376 loadChangelog (targetVersion , spinnerPane , changelogComponent );
381377 spinnerPane .setOnFailedAction (e -> loadChangelog (targetVersion , spinnerPane , changelogComponent ));
382378
@@ -405,25 +401,19 @@ private void loadChangelog(RemoteMod.Version version, SpinnerPane spinnerPane, C
405401 spinnerPane .setLoading (true );
406402 Task .supplyAsync (() -> {
407403 if (version .getChangelog () != null ) {
408- return version . getChangelog (). isBlank () ? null : version .getChangelog ();
404+ return StringUtils . nullIfBlank ( version .getChangelog () );
409405 } else {
410406 try {
411- String changelog = StringUtils .htmlToText (repository .getModChangelog (version .getModid (), version .getVersionId ()));
412- return changelog .isBlank () ? null : changelog ;
407+ return StringUtils .nullIfBlank (StringUtils .htmlToText (repository .getModChangelog (version .getModid (), version .getVersionId ())));
413408 } catch (UnsupportedOperationException e ) {
414- return null ;
409+ return Optional .< String > empty () ;
415410 }
416411 }
417412 }).whenComplete (Schedulers .javafx (), (result , exception ) -> {
418413 if (exception == null ) {
419- if (result != null ) {
420- componentList .getContent ().setAll (new HBox (new Text (result )));
421- } else {
422- componentList .getContent ().setAll ();
423- }
414+ result .ifPresent (s -> componentList .getContent ().setAll (new HBox (new Text (s ))));
424415 spinnerPane .setFailedReason (null );
425416 } else {
426- componentList .getContent ().setAll ();
427417 spinnerPane .setFailedReason (i18n ("download.failed.refresh" ));
428418 }
429419 spinnerPane .setLoading (false );
0 commit comments