Skip to content
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 update compatibility issue #2083

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class PreferencesView extends View<VBox, PreferencesModel, PreferencesCon
0, NetworkLoad.MAX_DIFFICULTY_ADJUSTMENT);
private static final ValidatorBase MAX_TRADE_PRICE_DEVIATION_VALIDATOR =
new PercentageValidator(Res.get("settings.preferences.trade.maxTradePriceDeviation.invalid", BisqEasyTradeService.MAX_TRADE_PRICE_DEVIATION * 100),
0, BisqEasyTradeService.MAX_TRADE_PRICE_DEVIATION);
0.01, BisqEasyTradeService.MAX_TRADE_PRICE_DEVIATION);
private static final double TEXT_FIELD_WIDTH = 500;

private final Button resetDontShowAgain, clearNotifications, addLanguageButton;
Expand Down
2 changes: 1 addition & 1 deletion i18n/src/main/resources/settings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ settings.preferences.trade.requiredTotalReputationScore=Min. required reputation
settings.preferences.trade.requiredTotalReputationScore.help=Restrict trading to trader with a min. reputation score
settings.preferences.network.minReputationScore.description.self=Custom min. required reputation score
settings.preferences.network.minReputationScore.description.fromSecManager=Min. required reputation score by Bisq Security Manager
settings.preferences.trade.maxTradePriceDeviation.invalid=Must be a value between 0 and {0}%
settings.preferences.trade.maxTradePriceDeviation.invalid=Must be a value between 1 and {0}%
settings.preferences.trade.minReputationScore.invalid=Must be a number between 0 and {0}
settings.preferences.network.minReputationScore.ignoreValueFromSecManager=Ignore value provided by Bisq Security Manager
settings.preferences.trade.closeMyOfferWhenTaken=Close my offer when taken
Expand Down
9 changes: 8 additions & 1 deletion settings/src/main/java/bisq/settings/SettingsStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ public bisq.settings.protobuf.SettingsStore toProto() {
}

public static SettingsStore fromProto(bisq.settings.protobuf.SettingsStore proto) {
// When users update from 2.0.2 the default value is 0. We require anyway a 1% as min. value so we use the
// fact that 0 is invalid to convert to the default value at updates.
// Can be removed once it's not expected anymore that users update from v2.0.2.
double maxTradePriceDeviation = proto.getMaxTradePriceDeviation();
if (maxTradePriceDeviation == 0) {
maxTradePriceDeviation = SettingsService.DEFAULT_MAX_TRADE_PRICE_DEVIATION;
}
return new SettingsStore(Cookie.fromProto(proto.getCookie()),
proto.getDontShowAgainMapMap().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
Expand All @@ -163,7 +170,7 @@ public static SettingsStore fromProto(bisq.settings.protobuf.SettingsStore proto
new HashSet<>(proto.getFavouriteMarketsList().stream()
.map(Market::fromProto).collect(Collectors.toSet())),
proto.getIgnoreMinRequiredReputationScoreFromSecManager(),
proto.getMaxTradePriceDeviation());
maxTradePriceDeviation);
}

@Override
Expand Down
Loading