Skip to content

Commit

Permalink
Fix for issue custom api key always saved even on cancel (#11977)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
u7663394 authored Oct 16, 2024
1 parent f2a93fb commit 758dab4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kbd>Tab</kbd> 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty();
private final StringProperty grobidURLProperty = new SimpleStringProperty("");

private final ListProperty<FetcherApiKey> apiKeys = new SimpleListProperty<>();
private final ObservableList<FetcherApiKey> apiKeys = FXCollections.observableArrayList();
private final ObjectProperty<FetcherApiKey> selectedApiKeyProperty = new SimpleObjectProperty<>();
private final BooleanProperty apikeyPersistProperty = new SimpleBooleanProperty();
private final BooleanProperty apikeyPersistAvailableProperty = new SimpleBooleanProperty();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -213,7 +216,7 @@ public StringProperty grobidURLProperty() {
return grobidURLProperty;
}

public ListProperty<FetcherApiKey> fetcherApiKeys() {
public ObservableList<FetcherApiKey> fetcherApiKeys() {
return apiKeys;
}

Expand Down

0 comments on commit 758dab4

Please sign in to comment.