fix(download): should update category list after download soruce changed.

This commit is contained in:
huanghongxun 2022-05-23 22:27:30 +08:00
parent 8cfde9d5c6
commit f12882a389

View File

@ -191,7 +191,10 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
} }
protected String getLocalizedCategoryIndent(ModDownloadListPageSkin.CategoryIndented category) { protected String getLocalizedCategoryIndent(ModDownloadListPageSkin.CategoryIndented category) {
return StringUtils.repeats(' ', category.indent * 4) + getLocalizedCategory(category.getCategory() == null ? "0" : category.getCategory().getId()); return StringUtils.repeats(' ', category.indent * 4) +
(category.getCategory() == null
? i18n("curse.category.0")
: getLocalizedCategory(category.getCategory().getId()));
} }
protected String getLocalizedOfficialPage() { protected String getLocalizedOfficialPage() {
@ -309,6 +312,7 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
categoryComboBox.setPromptText(i18n("mods.category")); categoryComboBox.setPromptText(i18n("mods.category"));
categoryComboBox.getSelectionModel().select(0); categoryComboBox.getSelectionModel().select(0);
categoryComboBox.setConverter(stringConverter(getSkinnable()::getLocalizedCategoryIndent)); categoryComboBox.setConverter(stringConverter(getSkinnable()::getLocalizedCategoryIndent));
FXUtils.onChangeAndOperate(getSkinnable().downloadSource, downloadSource -> {
Task.supplyAsync(() -> getSkinnable().repository.getCategories()) Task.supplyAsync(() -> getSkinnable().repository.getCategories())
.thenAcceptAsync(Schedulers.javafx(), categories -> { .thenAcceptAsync(Schedulers.javafx(), categories -> {
List<CategoryIndented> result = new ArrayList<>(); List<CategoryIndented> result = new ArrayList<>();
@ -318,6 +322,7 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
} }
categoryComboBox.getItems().setAll(result); categoryComboBox.getItems().setAll(result);
}).start(); }).start();
});
StackPane sortStackPane = new StackPane(); StackPane sortStackPane = new StackPane();
JFXComboBox<RemoteModRepository.SortType> sortComboBox = new JFXComboBox<>(); JFXComboBox<RemoteModRepository.SortType> sortComboBox = new JFXComboBox<>();