Skip to content

Commit

Permalink
Merge pull request #1022 from HenrikJannsen/deactivate_dispute_button…
Browse files Browse the repository at this point in the history
…g_after_opening_mediation

Deactivate dispute buttong after opening mediation
  • Loading branch information
alvasw authored Jul 19, 2023
2 parents d98bac5 + c95294b commit 8965b7f
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

package bisq.desktop.main.content.trade_apps.bisqEasy.chat.trade_state;

import bisq.chat.ChatService;
import bisq.chat.bisqeasy.channel.priv.BisqEasyPrivateTradeChatChannel;
import bisq.common.data.Triple;
import bisq.common.observable.Pin;
import bisq.desktop.ServiceProvider;
import bisq.desktop.common.Layout;
import bisq.desktop.common.observable.FxBindings;
import bisq.desktop.common.threading.UIThread;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.common.view.NavigationTarget;
Expand Down Expand Up @@ -77,19 +77,22 @@ private static class Controller implements bisq.desktop.common.view.Controller {
@Getter
private final View view;
private final MediationService mediationService;
private final ChatService chatService;
private Pin bisqEasyTradeStatePin;
private Pin bisqEasyTradeStatePin, isInMediationPin;

private Controller(ServiceProvider serviceProvider) {
mediationService = serviceProvider.getSupportService().getMediationService();
chatService = serviceProvider.getChatService();

model = new Model();
view = new View(model, this);
}

private void setSelectedChannel(BisqEasyPrivateTradeChatChannel channel) {
model.setSelectedChannel(channel);

if (isInMediationPin != null) {
isInMediationPin.unbind();
}
isInMediationPin = FxBindings.bind(model.getIsInMediation()).to(channel.isInMediationObservable());
}

private void setBisqEasyTrade(BisqEasyTrade bisqEasyTrade) {
Expand Down Expand Up @@ -170,6 +173,9 @@ public void onActivate() {

@Override
public void onDeactivate() {
if (isInMediationPin != null) {
isInMediationPin.unbind();
}
}

void onOpenTradeGuide() {
Expand Down Expand Up @@ -215,6 +221,7 @@ private static class Model implements bisq.desktop.common.view.Model {
private final StringProperty phase4Info = new SimpleStringProperty();
private final StringProperty phase5Info = new SimpleStringProperty();
private final BooleanProperty disputeButtonVisible = new SimpleBooleanProperty();
private final BooleanProperty isInMediation = new SimpleBooleanProperty();
}

public static class View extends bisq.desktop.common.view.View<VBox, Model, Controller> {
Expand Down Expand Up @@ -287,9 +294,11 @@ protected void onViewAttached() {
phase5Label.textProperty().bind(model.getPhase5Info());
disputeButton.visibleProperty().bind(model.getDisputeButtonVisible());
disputeButton.managedProperty().bind(model.getDisputeButtonVisible());
disputeButton.disableProperty().bind(model.getIsInMediation());

disputeButton.setOnAction(e -> controller.onOpenDispute());
openTradeGuide.setOnAction(e -> controller.onOpenTradeGuide());

phaseIndexPin = EasyBind.subscribe(model.getPhaseIndex(), this::phaseIndexChanged);
}

Expand All @@ -302,9 +311,11 @@ protected void onViewDetached() {
phase5Label.textProperty().unbind();
disputeButton.visibleProperty().unbind();
disputeButton.managedProperty().unbind();
disputeButton.disableProperty().unbind();

disputeButton.setOnAction(null);
openTradeGuide.setOnAction(null);

phaseIndexPin.unsubscribe();
}

Expand Down

0 comments on commit 8965b7f

Please sign in to comment.