Skip to content

Commit

Permalink
Merge pull request #2083 from HenrikJannsen/Fix-update-compatibility-…
Browse files Browse the repository at this point in the history
…issue

Fix update compatibility issue
  • Loading branch information
djing-chan authored Apr 17, 2024
2 parents 1c9c103 + 46e3f70 commit 83f29f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
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

0 comments on commit 83f29f6

Please sign in to comment.