-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for issue custom api key always saved even on cancel #11977
Changes from 9 commits
9da8440
501df1f
b6ee582
57147a1
01e76c9
f73afd1
b5dbaf2
b3159c2
5299a80
ecfeebb
c8fa338
5d79399
ae18ae8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,7 +56,8 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel { | |||||
private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty(); | ||||||
private final StringProperty grobidURLProperty = new SimpleStringProperty(""); | ||||||
|
||||||
private final ListProperty<FetcherApiKey> apiKeys = new SimpleListProperty<>(); | ||||||
// ObservableList to store API keys for editing in the UI | ||||||
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(); | ||||||
|
@@ -138,7 +139,11 @@ public void setValues() { | |||||
grobidEnabledProperty.setValue(grobidPreferences.isGrobidEnabled()); | ||||||
grobidURLProperty.setValue(grobidPreferences.getGrobidURL()); | ||||||
|
||||||
apiKeys.setValue(FXCollections.observableArrayList(preferences.getImporterPreferences().getApiKeys())); | ||||||
// Initialize apiKeys with a deep copy of the actual API Keys | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the comment |
||||||
apiKeys.setAll(preferences.getImporterPreferences().getApiKeys().stream() | ||||||
.map(apiKey -> new FetcherApiKey(apiKey.getName(), apiKey.shouldUse(), apiKey.getKey())) | ||||||
.collect(Collectors.toList())); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be simplified
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Careful, Collectors.toList() creates a new mutable array lust, .toList() an immutable one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OKay, so I reckon we'll continue using . I am a bit unsure about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we need an immutable list here. |
||||||
|
||||||
apikeyPersistAvailableProperty.setValue(OS.isKeyringAvailable()); | ||||||
apikeyPersistProperty.setValue(preferences.getImporterPreferences().shouldPersistCustomKeys()); | ||||||
catalogs.addAll(WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences) | ||||||
|
@@ -213,7 +218,7 @@ public StringProperty grobidURLProperty() { | |||||
return grobidURLProperty; | ||||||
} | ||||||
|
||||||
public ListProperty<FetcherApiKey> fetcherApiKeys() { | ||||||
public ObservableList<FetcherApiKey> fetcherApiKeys() { | ||||||
return apiKeys; | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comment