From d36a65dd1958d9366b222c7b4ae3b5572a225a98 Mon Sep 17 00:00:00 2001 From: Guochen Wang Date: Wed, 16 Oct 2024 22:10:54 +1100 Subject: [PATCH] Fix for issue custom api key always saved even on cancel (#11977) * Added temporary property to fix the issue. * Added comments. * Modified CHANGELOG.md * Rename variable and modify comments. * Use apiKeys directly and change to ObservableList * Remove comments. * Get an immutable list. --- CHANGELOG.md | 1 + .../gui/preferences/websearch/WebSearchTabViewModel.java | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a609a8267d..f3f004a10d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where recently opened files were not displayed in the main menu properly. [#9042](https://github.com/JabRef/jabref/issues/9042) - We fixed an issue where the DOI lookup would show an error when a DOI was found for an entry. [#11850](https://github.com/JabRef/jabref/issues/11850) - We fixed an issue where Tab cannot be used to jump to next field in some single-line fields. [#11785](https://github.com/JabRef/jabref/issues/11785) +- We fixed an issue where web search preferences "Custom API key" table modifications not discarded. [#11925](https://github.com/JabRef/jabref/issues/11925) ### Removed diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java index 37f33badb6a..550669211d2 100644 --- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java @@ -56,7 +56,7 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel { private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty(); private final StringProperty grobidURLProperty = new SimpleStringProperty(""); - private final ListProperty apiKeys = new SimpleListProperty<>(); + private final ObservableList apiKeys = FXCollections.observableArrayList(); private final ObjectProperty selectedApiKeyProperty = new SimpleObjectProperty<>(); private final BooleanProperty apikeyPersistProperty = new SimpleBooleanProperty(); private final BooleanProperty apikeyPersistAvailableProperty = new SimpleBooleanProperty(); @@ -138,7 +138,10 @@ public void setValues() { grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled()); grobidURLProperty.setValue(grobidPreferences.getGrobidURL()); - apiKeys.setValue(FXCollections.observableArrayList(preferences.getImporterPreferences().getApiKeys())); + apiKeys.setAll(preferences.getImporterPreferences().getApiKeys().stream() + .map(apiKey -> new FetcherApiKey(apiKey.getName(), apiKey.shouldUse(), apiKey.getKey())) + .toList()); + apikeyPersistAvailableProperty.setValue(OS.isKeyringAvailable()); apikeyPersistProperty.setValue(preferences.getImporterPreferences().shouldPersistCustomKeys()); catalogs.addAll(WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences) @@ -213,7 +216,7 @@ public StringProperty grobidURLProperty() { return grobidURLProperty; } - public ListProperty fetcherApiKeys() { + public ObservableList fetcherApiKeys() { return apiKeys; }