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

Remove redundant listener calls in data service [4] #1537

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6fcea60
Remove isPeerAddressVerified from Connection as we do the tor address…
djing-chan Dec 18, 2023
7519317
Only select channel if present
djing-chan Dec 18, 2023
f8a8b07
Refactor: Inline method
djing-chan Dec 18, 2023
c3201ec
Refactor: Move class, reduce visibility
djing-chan Dec 18, 2023
2d8f39f
Refactor: Rename package
djing-chan Dec 18, 2023
5ea7229
Refactor: Rename classes
djing-chan Dec 18, 2023
ccf0bd1
Make classes final, cleanups
djing-chan Dec 18, 2023
917fce2
Refactor: Rename Chat* MVC classes to BaseChat*
djing-chan Dec 18, 2023
64b8971
Refactor: Rename CommonChat* MVC classes to Chat*
djing-chan Dec 18, 2023
388ff35
Refactor: Move classes
djing-chan Dec 18, 2023
6822585
Refactor: Rename PublicChat* MVC classes to CommonPublicChat*
djing-chan Dec 18, 2023
2cf677a
Refactor: Rename ChatTab* MVC classes to CommonChatTab*
djing-chan Dec 18, 2023
5de8ac0
Refactor: Rename package
djing-chan Dec 18, 2023
256140d
Refactor: Add pub package and move classes
djing-chan Dec 18, 2023
1e70c44
Refactor: Rename package
djing-chan Dec 18, 2023
461af98
Add CommonPrivateChats* MVC classes
djing-chan Dec 18, 2023
ebd0253
Refactor: Rename Channel to ChannelTabButtonModel
djing-chan Dec 18, 2023
2f19467
Reduce visibility
djing-chan Dec 18, 2023
7226401
Sort channelTabButtonModels to get the first nav target selected.
djing-chan Dec 18, 2023
a1a9d48
Fix selection of private channel
djing-chan Dec 18, 2023
0b8fe99
Add methods for notification of transition start and end of exiting a…
djing-chan Dec 18, 2023
e7fbcce
Fix nullpointer
djing-chan Dec 19, 2023
b939be7
Remove TransitionedView implementations as it turned out it is not ne…
djing-chan Dec 19, 2023
b6c4219
Rename MessageDeliveryStatus.SENT to MessageDeliveryStatus.START_SEND…
djing-chan Dec 18, 2023
04d251d
Add TRY_ADD_TO_MAILBOX to MessageDeliveryStatus when starting the bro…
djing-chan Dec 18, 2023
c15520f
Add -bisq2-green-dim-50 color
djing-chan Dec 19, 2023
6b0845c
Add hashset for avoiding to send duplicated ack messages
djing-chan Dec 19, 2023
d0ac717
Fix comment in css
djing-chan Dec 19, 2023
189e94a
Create PeerGroupService at startup as it is used for persistence and …
djing-chan Dec 19, 2023
f811f28
Improve logs and comments
djing-chan Dec 19, 2023
6caca44
We get the listeners calls when data got added to the stores. The dup…
djing-chan Dec 19, 2023
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 @@ -32,6 +32,10 @@ public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label
return getIconForLabel(icon, iconSize, label, null);
}

public static void setAwesomeIconColor(Label label, String color) {
label.setStyle(label.getStyle() + "; -fx-text-fill: " + color);
}

public static Label getIconForLabel(AwesomeIcon icon, Label label, String fontSize) {
AwesomeDude.setIcon(label, icon, fontSize);
return label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
import bisq.desktop.common.view.TransitionedView;
import bisq.desktop.common.view.View;
import bisq.settings.SettingsService;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import javafx.animation.FadeTransition;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.animation.*;
import javafx.beans.value.ChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Camera;
Expand All @@ -46,10 +39,14 @@
import javafx.scene.layout.Region;
import javafx.scene.transform.Rotate;
import javafx.util.Duration;
import javax.annotation.Nullable;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;

@Slf4j
public class Transitions {

Expand Down Expand Up @@ -92,12 +89,16 @@ public void apply(Node node) {
private static Map<String, Timeline> removeEffectTimeLineByNodeId = new HashMap<>();
private static Map<String, ChangeListener<Effect>> effectChangeListenerByNodeId = new HashMap<>();

public static void fadeIn(Node node) {
fadeIn(node, DEFAULT_DURATION);
public static FadeTransition fadeIn(Node node) {
return fadeIn(node, DEFAULT_DURATION);
}

public static FadeTransition fadeIn(Node node, int duration) {
return fadeIn(node, duration, null);
}

public static void fadeIn(Node node, int duration) {
fadeIn(node, duration, null);
public static FadeTransition fadeIn(Node node, Runnable finishedHandler) {
return fadeIn(node, DEFAULT_DURATION, finishedHandler);
}

public static FadeTransition fadeIn(Node node, int duration, @Nullable Runnable finishedHandler) {
Expand Down Expand Up @@ -446,17 +447,24 @@ public static void transitContentViews(View<? extends Parent, ? extends Model, ?

UIScheduler.run(() -> {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onStartTransition();
((TransitionedView) newView).onInTransitionStarted();
}
fadeIn(nodeIn,
DEFAULT_DURATION / 4,
() -> {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onTransitionCompleted();
((TransitionedView) newView).onInTransitionCompleted();
}
});
}).after(DEFAULT_DURATION / 2);

if (oldView instanceof TransitionedView) {
((TransitionedView) oldView).onOutTransitionStarted();
}
slideOutRight(nodeOut, () -> {
if (oldView instanceof TransitionedView) {
((TransitionedView) oldView).onOutTransitionCompleted();
}
Parent parent = nodeOut.getParent();
if (parent != null) {
if (parent instanceof Pane) {
Expand All @@ -467,13 +475,13 @@ public static void transitContentViews(View<? extends Parent, ? extends Model, ?
});
} else {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onStartTransition();
((TransitionedView) newView).onInTransitionStarted();
}
Transitions.fadeIn(nodeIn,
DEFAULT_DURATION,
() -> {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onTransitionCompleted();
((TransitionedView) newView).onInTransitionCompleted();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class ViewTransition {
@Nullable
private Region oldViewRoot, newViewRoot;
@Nullable
private final View<? extends Parent, ? extends Model, ? extends Controller> oldView;
@Nullable
private View<? extends Parent, ? extends Model, ? extends Controller> newView;
@Nullable
private Timeline slideOutTimeline;
Expand All @@ -47,27 +49,46 @@ public class ViewTransition {
private FadeTransition fadeinTransition;
private double oldViewX;

public ViewTransition(@Nullable Region oldViewRoot,
public ViewTransition(@Nullable View<? extends Parent, ? extends Model, ? extends Controller> oldView,
View<? extends Parent, ? extends Model, ? extends Controller> newView) {
this.oldViewRoot = oldViewRoot;
this.oldView = oldView;
this.newView = newView;
oldViewRoot = oldView != null ? oldView.getRoot() : null;
newViewRoot = newView.getRoot();
if (!Transitions.getUseAnimations()) {
if (oldView != null) {
remove(oldViewRoot);
if (oldView instanceof TransitionedView) {
((TransitionedView) oldView).onOutTransitionStarted();
((TransitionedView) oldView).onOutTransitionCompleted();
}
}
newViewRoot.setOpacity(1);
remove(oldViewRoot);
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onInTransitionStarted();
((TransitionedView) newView).onInTransitionCompleted();
}
return;
}

int defaultDuration = Transitions.DEFAULT_DURATION;
newViewRoot.setOpacity(0);
if (oldViewRoot == null) {
fadeIn(defaultDuration);
fadeInNewView(defaultDuration);
} else {
oldViewX = oldViewRoot.getTranslateX();
scheduler = UIScheduler.run(() -> fadeIn(MathUtils.roundDoubleToInt(defaultDuration / 2d))).after(defaultDuration / 2);
scheduler = UIScheduler.run(() -> fadeInNewView(MathUtils.roundDoubleToInt(defaultDuration / 2d)))
.after(defaultDuration / 2);
if (slideOutTimeline != null) {
slideOutTimeline.stop();
}
if (oldView instanceof TransitionedView) {
((TransitionedView) oldView).onOutTransitionStarted();
}
slideOutTimeline = Transitions.slideOutRight(oldViewRoot, () -> {
if (oldView instanceof TransitionedView) {
((TransitionedView) oldView).onOutTransitionCompleted();
}
remove(this.oldViewRoot);
this.oldViewRoot = null;
});
Expand Down Expand Up @@ -109,9 +130,9 @@ private void remove(Region region) {
}
}

private void fadeIn(int duration) {
private void fadeInNewView(int duration) {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onStartTransition();
((TransitionedView) newView).onInTransitionStarted();
}
if (fadeinTransition != null) {
fadeinTransition.stop();
Expand All @@ -120,7 +141,7 @@ private void fadeIn(int duration) {
duration,
() -> {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onTransitionCompleted();
((TransitionedView) newView).onInTransitionCompleted();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import javax.annotation.Nullable;



@Slf4j
public abstract class TabView<M extends TabModel, C extends TabController<M>> extends NavigationView<VBox, M, C>
implements TransitionedView {
Expand All @@ -56,7 +55,6 @@ public abstract class TabView<M extends TabModel, C extends TabController<M>> ex
@Getter
protected Pane topBox;
private Subscription selectedTabButtonSubscription, rootWidthSubscription, layoutDoneSubscription;
private boolean transitionStarted;
private ChangeListener<View<? extends Parent, ? extends Model, ? extends Controller>> viewListener;

public TabView(M model, C controller) {
Expand All @@ -80,7 +78,6 @@ public TabView(M model, C controller) {
void onViewAttachedInternal() {
selectionMarker.setLayoutX(0);
selectionMarker.setPrefWidth(0);
transitionStarted = false;

line.prefWidthProperty().bind(root.widthProperty().subtract(2 * lineSidePadding));
model.getTabButtons().forEach(tabButton ->
Expand Down Expand Up @@ -112,7 +109,15 @@ void onViewAttachedInternal() {
protected void onChildView(View<? extends Parent, ? extends Model, ? extends Controller> oldValue,
View<? extends Parent, ? extends Model, ? extends Controller> newValue) {
if (oldValue != null) {
Transitions.slideOutRight(oldValue.getRoot(), () -> setNewContent(newValue));
if (oldValue instanceof TransitionedView) {
((TransitionedView) oldValue).onOutTransitionStarted();
}
Transitions.slideOutRight(oldValue.getRoot(), () -> {
if (oldValue instanceof TransitionedView) {
((TransitionedView) oldValue).onOutTransitionCompleted();
}
setNewContent(newValue);
});
} else {
setNewContent(newValue);
}
Expand All @@ -126,7 +131,14 @@ private void setNewContent(View<? extends Parent, ? extends Model, ? extends Con
scrollPane.setContent(newValue.getRoot());
scrollPane.setVvalue(0);

Transitions.fadeIn(newValue.getRoot());
if (newValue instanceof TransitionedView) {
((TransitionedView) newValue).onInTransitionStarted();
}
Transitions.fadeIn(newValue.getRoot(), () -> {
if (newValue instanceof TransitionedView) {
((TransitionedView) newValue).onInTransitionCompleted();
}
});
} else {
scrollPane.setContent(null);
}
Expand All @@ -150,15 +162,10 @@ void onViewDetachedInternal() {
}

@Override
public void onStartTransition() {
transitionStarted = true;
public void onInTransitionStarted() {
UIThread.runOnNextRenderFrame(this::maybeAnimateMark);
}

@Override
public void onTransitionCompleted() {
}

protected boolean isRightSide() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

package bisq.desktop.common.view;

/**
* Interface for views which want to get notified if a transition was applied to it (usually by some outer container)
* This is helpful for cascaded animations.
* E.g. ContentView fades in the PortfolioView after a short delay, the PortfolioView listens to onStartTransition to
* start its tabButton animation when fadein has started.
*/
public interface TransitionedView {
void onTransitionCompleted();
default void onOutTransitionStarted() {
}

default void onOutTransitionCompleted() {
}

default void onInTransitionStarted() {
}

void onStartTransition();
default void onInTransitionCompleted() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import bisq.desktop.main.content.academy.AcademyController;
import bisq.desktop.main.content.authorized_role.AuthorizedRoleController;
import bisq.desktop.main.content.bisq_easy.BisqEasyController;
import bisq.desktop.main.content.chat.navigation.ChatContainerController;
import bisq.desktop.main.content.chat.common.CommonChatTabController;
import bisq.desktop.main.content.dashboard.DashboardController;
import bisq.desktop.main.content.settings.SettingsController;
import bisq.desktop.main.content.trade_apps.TradeAppsController;
Expand Down Expand Up @@ -70,16 +70,16 @@ protected Optional<? extends Controller> createController(NavigationTarget navig
return Optional.of(new DashboardController(serviceProvider));
}
case DISCUSSION: {
return Optional.of(new ChatContainerController(serviceProvider, ChatChannelDomain.DISCUSSION, NavigationTarget.DISCUSSION));
return Optional.of(new CommonChatTabController(serviceProvider, ChatChannelDomain.DISCUSSION, NavigationTarget.DISCUSSION));
}
case ACADEMY: {
return Optional.of(new AcademyController(serviceProvider));
}
case EVENTS: {
return Optional.of(new ChatContainerController(serviceProvider, ChatChannelDomain.EVENTS, NavigationTarget.EVENTS));
return Optional.of(new CommonChatTabController(serviceProvider, ChatChannelDomain.EVENTS, NavigationTarget.EVENTS));
}
case SUPPORT: {
return Optional.of(new ChatContainerController(serviceProvider, ChatChannelDomain.SUPPORT, NavigationTarget.SUPPORT));
return Optional.of(new CommonChatTabController(serviceProvider, ChatChannelDomain.SUPPORT, NavigationTarget.SUPPORT));
}
case TRADE_PROTOCOLS: {
return Optional.of(new TradeAppsController(serviceProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import bisq.desktop.common.threading.UIScheduler;
import bisq.desktop.common.view.*;
import bisq.desktop.main.content.chat.ChatView;
import bisq.desktop.main.content.chat.BaseChatView;
import bisq.desktop.main.notification.NotificationPanelView;
import javafx.geometry.Insets;
import javafx.scene.Parent;
Expand Down Expand Up @@ -75,6 +75,6 @@ protected double getSelectionMarkerX(TabButton selectedTabButton) {

@Override
protected boolean useFitToHeight(View<? extends Parent, ? extends Model, ? extends Controller> childView) {
return childView instanceof ChatView;
return childView instanceof BaseChatView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public ContentView(ContentModel model, ContentController controller) {
log.warn("We did not add the new child view as we still had it in out children list. " +
"This should not happen as the viewTransition.stop() call should remove any old dangling child view. New child view={}", newValue);
}
Region oldValueRoot = oldValue != null ? oldValue.getRoot() : null;
viewTransition = new ViewTransition(oldValueRoot, newValue);
viewTransition = new ViewTransition(oldValue, newValue);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import bisq.desktop.common.view.Controller;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.main.content.bisq_easy.trade_wizard.TradeWizardController;
import bisq.desktop.main.content.chat.ChatController;
import bisq.desktop.main.content.chat.BaseChatController;
import bisq.desktop.main.content.components.MarketImageComposition;
import bisq.offer.bisq_easy.BisqEasyOffer;
import bisq.settings.SettingsService;
Expand All @@ -53,7 +53,7 @@
import static com.google.common.base.Preconditions.checkArgument;

@Slf4j
public class BisqEasyOfferbookController extends ChatController<BisqEasyOfferbookView, BisqEasyOfferbookModel> {
public final class BisqEasyOfferbookController extends BaseChatController<BisqEasyOfferbookView, BisqEasyOfferbookModel> {
private final BisqEasyOfferbookSelectionService bisqEasyOfferbookSelectionService;
private final SettingsService settingsService;
private final BisqEasyOfferbookChannelService bisqEasyOfferbookChannelService;
Expand Down Expand Up @@ -148,6 +148,7 @@ public void onActivate() {
public void onDeactivate() {
searchTextPin.unsubscribe();
offerOnlySettingsPin.unbind();
selectedChannelPin.unbind();
bisqEasyPrivateTradeChatChannelsPin.unbind();

resetSelectedChildTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import bisq.bisq_easy.NavigationTarget;
import bisq.chat.ChatChannelDomain;
import bisq.desktop.main.content.chat.ChatModel;
import bisq.desktop.main.content.chat.BaseChatModel;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
Expand All @@ -33,7 +33,7 @@

@Slf4j
@Getter
public class BisqEasyOfferbookModel extends ChatModel {
public final class BisqEasyOfferbookModel extends BaseChatModel {
private final BooleanProperty offerOnly = new SimpleBooleanProperty();
private final BooleanProperty isTradeChannelVisible = new SimpleBooleanProperty();
private final BooleanProperty showFilterOverlay = new SimpleBooleanProperty();
Expand Down
Loading