Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Profile switch2 #5

Merged
merged 2 commits into from
Oct 19, 2023
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
6 changes: 5 additions & 1 deletion frontend/styles/BisqEasyView.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
body {
--lumo-primary-text-color: --bisq-white;
--_lumo-button-color: --bisq-white;
}

.replyArea {
width: 100%;
background-color: var(--bisq-black);
Expand All @@ -9,7 +14,6 @@
flex-direction: row;
justify-content: space-between;
}

.messDate {
padding-left: 15px;
opacity: 0;
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/bisq/web/ui/admin/UserProfileView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ public UserProfileView() {
profileSelection = UIUtils.create(new Select<UserIdentity>(), selectBar::add, "profileSelection");
profileSelection.setLabel(Res.get("settings.userProfile.select"));
profileSelection.setItemLabelGenerator(UserIdentity::getNickName);
profileSelection.addValueChangeListener(ev -> {
if (ev.isFromClient()) {
getPresenter().selectProfile(new ProfileBean().loadFromIdentity(ev.getValue()));
}
});
profileSelection.addValueChangeListener(UIUtils.onClientEvent(ev ->
getPresenter().selectProfile(new ProfileBean().loadFromIdentity(ev.getValue()))));


Button createButton = UIUtils.create(new Button(Res.get("settings.userProfile.createNewProfile")), selectBar::add, "createButton outlined-button");
createButton.addClickListener(ev -> presenter.createNewProfile());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/bisq/web/ui/easy/BisqEasyPresenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void sendMessage(UserIdentity userIdentity, String text) {
.filter(msg -> StringUtils.isNotBlank(msg.getText())) //
.flatMap(this::findAuthor) //
.map(authorProfile -> new Quotation(authorProfile.getNym(), authorProfile.getNickName(), authorProfile.getPubKeyHash(), replyMessage.getText()));
replyMessage = null;

if (settingsService.getOffersOnly().get()) {
settingsService.setOffersOnly(false);
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/bisq/web/ui/easy/BisqEasyView.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class BisqEasyView extends HorizontalLayout implements IBisqEasyView {
protected final Checkbox offerOnlyCheck;
protected final Select<UserIdentity> identitySelect;
@Getter
private BisqEasyPresenter presenter = new BisqEasyPresenter(this);
protected final BisqEasyPresenter presenter = new BisqEasyPresenter(this);


public BisqEasyView() {
Expand All @@ -87,11 +87,7 @@ public BisqEasyView() {
tradeChannelBox.setItems(UIUtils.providerFrom(this, presenter.publicTradeChannels()));
tradeChannelBox.setItemLabelGenerator(Channel::getDisplayString);
UIUtils.sortByLabel(tradeChannelBox);
tradeChannelBox.addValueChangeListener(ev -> {
if (ev.isFromClient()) {
boxSelection();
}
});
tradeChannelBox.addValueChangeListener(UIUtils.onClientEvent(ev -> boxSelection()));
tradeChannelBox.setVisible(false);
tradeChannelBox.setPlaceholder("Add market channel");// Res.get("tradeChat.addMarketChannel"));

Expand Down Expand Up @@ -308,7 +304,7 @@ public void stateChanged() {
if (publicTradeChannel != null) {
// BisqContext.get().getTradeChannelSelectionService().getPublicTradeChannelService().
identitySelect.setValue(presenter.myLastProfileInChannel() //
.or(() -> identitySelect.getOptionalValue()) //
.or(identitySelect::getOptionalValue) //
.orElseGet(() -> BisqContext.get().getUserIdentity())
);
}
Expand Down
30 changes: 12 additions & 18 deletions src/main/java/bisq/web/util/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import bisq.common.observable.ObservableArray;
import bisq.common.observable.ObservableSet;
import com.vaadin.flow.component.ClickEvent;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.HasStyle;
import com.vaadin.flow.component.*;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
Expand Down Expand Up @@ -117,11 +114,7 @@ public static <T> Stream<T> nullSafeStream(T[] streamable) {
}

public static <T> Collection<T> nullSafeCollection(Collection<T> col) {
if (col == null) {
return Collections.EMPTY_LIST;
} else {
return col;
}
return Objects.requireNonNullElse(col, Collections.EMPTY_LIST);
}

/**
Expand All @@ -132,11 +125,7 @@ public static <T> Collection<T> nullSafeCollection(Collection<T> col) {
* @return
*/
public static String formatString(String template, String... args) {
// String[] array = (String[]) IntStream.range(1, args.length + 1).mapToObj(i -> "{" + i +
// "}").collect(Collectors.toList()).toArray();
if (template == null) {
throw new NullPointerException();
}
Objects.requireNonNull(template);
String[] array = new String[ args.length ];
for (int i = 0; i < args.length; ) {
array[ i ] = "{" + ++i + "}";
Expand Down Expand Up @@ -182,7 +171,7 @@ public static <T> ListDataProvider<T> providerFrom(Component comp, ObservableSet
* Why doesnt Vaading write a class SerializableComparator, which is actually worth the name?
*/
public static <T> SerializableComparator<T> toS(Comparator<T> c) {
return (SerializableComparator<T>) c::compare;
return c::compare;
}

public static <T> void sortByLabel(ComboBox<T> box) {
Expand All @@ -192,9 +181,14 @@ public static <T> void sortByLabel(ComboBox<T> box) {
public static <T, U extends Comparable<? super U>> SerializableComparator<T> comparing(Function<T, U> compFunction) {
return toS(Comparator.comparing(compFunction));
}
}

// install observer listener

public static <C extends AbstractField<C, T>, T> HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<C, T>> onClientEvent(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<C, T>> sup) {
return ev -> {
if (ev.isFromClient()) {
sup.valueChanged(ev);
}
};
}
}