show warning in preferences if currencies could not be retrieved from exchange rate source

This commit is contained in:
Craig Raw 2023-07-17 11:17:16 +02:00
parent 4c408ac7b1
commit 31bd64f821
3 changed files with 19 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -45,6 +46,9 @@ public class GeneralPreferencesController extends PreferencesDetailController {
@FXML @FXML
private ComboBox<ExchangeSource> exchangeSource; private ComboBox<ExchangeSource> exchangeSource;
@FXML
private Label currenciesLoadWarning;
@FXML @FXML
private UnlabeledToggleSwitch loadRecentWallets; private UnlabeledToggleSwitch loadRecentWallets;
@ -87,6 +91,9 @@ public class GeneralPreferencesController extends PreferencesDetailController {
EventManager.get().post(new FeeRatesSourceChangedEvent(newValue)); EventManager.get().post(new FeeRatesSourceChangedEvent(newValue));
}); });
currenciesLoadWarning.managedProperty().bind(currenciesLoadWarning.visibleProperty());
currenciesLoadWarning.setVisible(false);
blockExplorers.setItems(getBlockExplorerList()); blockExplorers.setItems(getBlockExplorerList());
blockExplorers.setConverter(new StringConverter<>() { blockExplorers.setConverter(new StringConverter<>() {
@Override @Override
@ -237,6 +244,8 @@ public class GeneralPreferencesController extends PreferencesDetailController {
fiatCurrency.setDisable(true); fiatCurrency.setDisable(true);
} }
currenciesLoadWarning.setVisible(exchangeSource.getValue() != ExchangeSource.NONE && currencies.isEmpty());
//Always fire event regardless of previous selection to update rates //Always fire event regardless of previous selection to update rates
EventManager.get().post(new FiatCurrencySelectedEvent(exchangeSource.getValue(), fiatCurrency.getValue())); EventManager.get().post(new FiatCurrencySelectedEvent(exchangeSource.getValue(), fiatCurrency.getValue()));

View file

@ -320,3 +320,7 @@ CellView > .text-input.text-field {
-fx-background-color: -fx-control-inner-background; -fx-background-color: -fx-control-inner-background;
} }
.field-warning {
-fx-text-fill: rgb(238, 210, 2);
-fx-padding: 0 0 0 12;
}

View file

@ -15,6 +15,7 @@
<?import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch?> <?import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch?>
<?import com.sparrowwallet.sparrow.control.HelpLabel?> <?import com.sparrowwallet.sparrow.control.HelpLabel?>
<?import com.sparrowwallet.sparrow.net.FeeRatesSource?> <?import com.sparrowwallet.sparrow.net.FeeRatesSource?>
<?import org.controlsfx.glyphfont.Glyph?>
<GridPane hgap="10.0" vgap="10.0" stylesheets="@preferences.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.preferences.GeneralPreferencesController"> <GridPane hgap="10.0" vgap="10.0" stylesheets="@preferences.css, @../general.css" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.preferences.GeneralPreferencesController">
<padding> <padding>
@ -60,6 +61,11 @@
</FXCollections> </FXCollections>
</items> </items>
</ComboBox> </ComboBox>
<Label fx:id="currenciesLoadWarning" text="Error retrieving currencies">
<graphic>
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="12" icon="EXCLAMATION_TRIANGLE" styleClass="field-warning" />
</graphic>
</Label>
</Field> </Field>
</Fieldset> </Fieldset>
<Fieldset inputGrow="SOMETIMES" text="Wallet" styleClass="wideLabelFieldSet"> <Fieldset inputGrow="SOMETIMES" text="Wallet" styleClass="wideLabelFieldSet">