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

Improve user profile card handling #3103

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 @@ -215,7 +215,6 @@ protected void onViewAttached() {
!isMakerRequester ? Res.get("confirmation.yes") : Res.get("confirmation.no")
));


tradeId.getSecond().setText(item.getShortTradeId());
} else {
makerProfileDisplay.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ private static UserProfileDisplay applyTraderToTableCell(TableCell<ListItem, Lis
ListItem.Trader trader) {
UserProfileDisplay userProfileDisplay = new UserProfileDisplay();
userProfileDisplay.setUserProfile(trader.getUserProfile());
userProfileDisplay.configureOpenProfileCard(trader.getUserProfile());
if (isRequester) {
userProfileDisplay.getStyleClass().add("mediator-table-requester");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public void onDeactivate() {
}

void onContactUser(BannedUserProfileData data) {
ChatChannelDomain chatChannelDomain = ChatChannelDomain.SUPPORT;
moderatorService.contactUser(chatChannelDomain, data.getUserProfile(), Optional.empty(), false)
ChatChannelDomain chatChannelDomain = ChatChannelDomain.DISCUSSION;
moderatorService.contactUser(data.getUserProfile(), Optional.empty(), false)
.whenComplete((result, throwable) -> UIThread.run(() -> {
if (throwable == null) {
SendMessageResult.findAnyErrorMsg(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public void onDeactivate() {
}

void onContactUser(ReportToModeratorMessage message, UserProfile userProfile, boolean isReportingUser) {
ChatChannelDomain chatChannelDomain = message.getChatChannelDomain();
ChatChannelDomain chatChannelDomain = ChatChannelDomain.DISCUSSION;
Optional<String> citation = isReportingUser ? Optional.of(message.getMessage()) : Optional.empty();
moderatorService.contactUser(chatChannelDomain, userProfile, citation, isReportingUser)
moderatorService.contactUser(userProfile, citation, isReportingUser)
.whenComplete((result, throwable) -> UIThread.run(() -> {
if (throwable == null) {
SendMessageResult.findAnyErrorMsg(result)
Expand Down Expand Up @@ -171,6 +171,7 @@ protected void onViewDetached() {

///////////////////////////////////////////////////////////////////////////////////////////////////
// ReportTable

///////////////////////////////////////////////////////////////////////////////////////////////////

private void configTableView() {
Expand Down Expand Up @@ -246,6 +247,7 @@ protected void updateItem(ListItem item, boolean empty) {
userNameLabel.setText(reporterUserName);
UserProfile reporterUserProfile = item.getReporterUserProfile().get();
userProfileIcon.setUserProfile(reporterUserProfile);

button.setText(Res.get("authorizedRole.moderator.table.contact") + " " + StringUtils.truncate(reporterUserName, 8));
button.setOnAction(e -> controller.onContactUser(item.getReportToModeratorMessage(), reporterUserProfile, true));
setGraphic(hBox);
Expand Down Expand Up @@ -282,8 +284,10 @@ protected void updateItem(ListItem item, boolean empty) {
userNameLabel.setText(accusedUserName);
UserProfile accusedUserProfile = item.getAccusedUserProfile();
userProfileIcon.setUserProfile(accusedUserProfile);

button.setText(Res.get("authorizedRole.moderator.table.contact") + " " + StringUtils.truncate(accusedUserName, 8));
button.setOnAction(e -> controller.onContactUser(item.getReportToModeratorMessage(), accusedUserProfile, false));

setGraphic(hBox);
} else {
userProfileIcon.dispose();
Expand Down Expand Up @@ -380,6 +384,7 @@ protected void updateItem(ListItem item, boolean empty) {

///////////////////////////////////////////////////////////////////////////////////////////////////
// TableItems

///////////////////////////////////////////////////////////////////////////////////////////////////

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ protected void onViewAttached() {

userProfilePin = EasyBind.subscribe(model.getPeersUserProfile(), userProfile -> {
peersUserProfileDisplay.setUserProfile(userProfile);
peersUserProfileDisplay.configureOpenProfileCard(userProfile, model.getChannel().get());
});
reputationScorePin = EasyBind.subscribe(model.getReputationScore(), peersUserProfileDisplay::setReputationScore);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import static bisq.chat.ChatChannelDomain.BISQ_EASY_OPEN_TRADES;

@Slf4j
public class BuyerState2a extends BaseState {
private final Controller controller;
Expand Down Expand Up @@ -94,7 +92,7 @@ public void onActivate() {

// Report to moderator
String message = "Account data of " + peerUserName + " is banned: " + sellersAccountData;
moderatorService.reportUserProfile(peer, message, BISQ_EASY_OPEN_TRADES);
moderatorService.reportUserProfile(peer, message);

// We reject the trade to avoid the banned user can continue
bisqEasyTradeService.cancelTrade(bisqEasyTrade);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ protected void openProfileCard(UserProfile userProfile) {
Navigation.navigateTo(NavigationTarget.PROFILE_CARD,
new ProfileCardController.InitData(
userProfile,
model.getSelectedChannel(),
chatMessageContainerController::refreshMessages));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,13 @@ public void onSaveEditedMessage(ChatMessage chatMessage, String editedText) {
}

public void onReportUser(ChatMessage chatMessage) {
ChatChannelDomain chatChannelDomain = model.getSelectedChannel().get().getChatChannelDomain();
if (chatMessage instanceof PrivateChatMessage<?> privateChatMessage) {
Navigation.navigateTo(NavigationTarget.REPORT_TO_MODERATOR,
new ReportToModeratorWindow.InitData(privateChatMessage.getSenderUserProfile(), chatChannelDomain));
new ReportToModeratorWindow.InitData(privateChatMessage.getSenderUserProfile()));
} else {
userProfileService.findUserProfile(chatMessage.getAuthorUserProfileId())
.ifPresent(accusedUserProfile -> Navigation.navigateTo(NavigationTarget.REPORT_TO_MODERATOR,
new ReportToModeratorWindow.InitData(accusedUserProfile, chatChannelDomain)));
new ReportToModeratorWindow.InitData(accusedUserProfile)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,13 @@ protected void onViewAttached() {
if (userProfile != null) {
chatPeerUserProfileDisplay.setUserProfile(userProfile);
chatPeerUserProfileDisplay.setReputationScore(model.getPeersReputationScore());
chatPeerUserProfileDisplay.configureOpenProfileCard(userProfile, model.getSelectedChannel());
}
});

myUserProfilePin = EasyBind.subscribe(model.getMyUserProfile(), userProfile -> {
if (userProfile != null) {
chatMyUserProfileDisplay.setUserProfile(userProfile);
chatMyUserProfileDisplay.setReputationScore(model.getMyUserReputationScore());
chatMyUserProfileDisplay.configureOpenProfileCard(userProfile, model.getSelectedChannel());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package bisq.desktop.main.content.components;

import bisq.chat.ChatChannelDomain;
import bisq.desktop.ServiceProvider;
import bisq.desktop.common.view.InitWithDataController;
import bisq.desktop.components.controls.MaterialTextArea;
Expand Down Expand Up @@ -49,12 +48,10 @@ public class ReportToModeratorWindow {
@EqualsAndHashCode
@ToString
public static class InitData {
private final ChatChannelDomain chatChannelDomain;
private final UserProfile accusedUserProfile;

public InitData(UserProfile accusedUserProfile, ChatChannelDomain chatChannelDomain) {
public InitData(UserProfile accusedUserProfile) {
this.accusedUserProfile = accusedUserProfile;
this.chatChannelDomain = chatChannelDomain;
}
}

Expand Down Expand Up @@ -83,7 +80,6 @@ private Controller(ServiceProvider serviceProvider) {
@Override
public void initWithData(ReportToModeratorWindow.InitData initData) {
model.setAccusedUserProfile(initData.getAccusedUserProfile());
model.setChatChannelDomain(initData.getChatChannelDomain());
}

@Override
Expand All @@ -105,7 +101,7 @@ void onReport() {
return;
}

moderatorService.reportUserProfile(model.getAccusedUserProfile(), message, model.getChatChannelDomain());
moderatorService.reportUserProfile(model.getAccusedUserProfile(), message);
onCancel();
}

Expand All @@ -124,8 +120,6 @@ private static class Model implements bisq.desktop.common.view.Model {
public final StringProperty message = new SimpleStringProperty("");
public final BooleanProperty reportButtonDisabled = new SimpleBooleanProperty();
@Setter
private ChatChannelDomain chatChannelDomain;
@Setter
private UserProfile accusedUserProfile;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package bisq.desktop.main.content.components;

import bisq.bisq_easy.NavigationTarget;
import bisq.chat.ChatChannel;
import bisq.chat.ChatMessage;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.main.content.user.profile_card.ProfileCardController;
import bisq.user.profile.UserProfile;
Expand Down Expand Up @@ -93,10 +91,10 @@ public void setUserProfile(@Nullable UserProfile userProfile) {
if (userProfile != null) {
userName.setText(userProfile.getUserName());
}
configureOpenProfileCard(userProfile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think adding this by default makes a great UX.
In particular, when the user profile display or icon are used in tables or dropdowns, clicking on the user icon will do two things: open the popup and select that row/menu. If the user's intention was to the latter, then it is annoying and confusing. Therefore, I would stick to adding it in a case by case scenario. See: #3041 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... i got confused that in some cases i could not open it like in offer list and some other places.
We could invert the handling by using a method to not open a popup if not wanted, that would reduce the cases where we need to deal with it. But not too strong opinion on that. We can also revert it, but IMO it was missing in some places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which cases do you have in mind to not apply it?

}

public void dispose() {
userProfileIcon.setOnMouseClicked(null);
userName.setOnMouseClicked(null);
userProfileIcon.dispose();
setReputationScore(null);
Expand Down Expand Up @@ -127,17 +125,8 @@ public void setReputationScoreDisplayScale(double scale) {
}

public void configureOpenProfileCard(UserProfile userProfile) {
configureOpenProfileCard(userProfile, null);
}

public void configureOpenProfileCard(UserProfile userProfile, @Nullable ChatChannel<? extends ChatMessage> chatChannel) {
userProfileIcon.setOnMouseClicked(e ->
Navigation.navigateTo(NavigationTarget.PROFILE_CARD,
new ProfileCardController.InitData(userProfile, chatChannel)));
userName.setOnMouseClicked(e ->
Navigation.navigateTo(NavigationTarget.PROFILE_CARD,
new ProfileCardController.InitData(userProfile, chatChannel)));
userProfileIcon.getStyleClass().add("hand-cursor");
Navigation.navigateTo(NavigationTarget.PROFILE_CARD, new ProfileCardController.InitData(userProfile)));
userName.getStyleClass().add("hand-cursor");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@

package bisq.desktop.main.content.components;

import bisq.bisq_easy.NavigationTarget;
import bisq.common.util.StringUtils;
import bisq.desktop.common.threading.UIThread;
import bisq.desktop.common.view.Navigation;
import bisq.desktop.components.cathash.CatHash;
import bisq.desktop.components.controls.BisqTooltip;
import bisq.desktop.main.content.user.profile_card.ProfileCardController;
import bisq.i18n.Res;
import bisq.user.profile.UserProfile;
import javafx.beans.property.SimpleStringProperty;
Expand Down Expand Up @@ -69,6 +72,7 @@ public UserProfileIcon(double size) {
setAlignment(Pos.CENTER);
getChildren().addAll(catHashImageView, livenessIndicator);
sceneChangeListener = (ov, oldValue, newScene) -> handleSceneChange(oldValue, newScene);
this.getStyleClass().add("hand-cursor");
}

private void handleSceneChange(Scene oldValue, Scene newScene) {
Expand Down Expand Up @@ -110,11 +114,15 @@ public void setUserProfile(@Nullable UserProfile userProfile) {
} else {
livenessScheduler.start(userProfile);
}

setOnMouseClicked(e ->
Navigation.navigateTo(NavigationTarget.PROFILE_CARD, new ProfileCardController.InitData(userProfile)));
}

public void dispose() {
livenessScheduler.dispose();
catHashImageView.setImage(null);
setOnMouseClicked(null);
userProfile = null;
Tooltip.uninstall(this, tooltip);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ protected void onViewAttached() {
userProfileDisplay.setUserProfile(selectedUserIdentity.getUserProfile());
userProfileDisplay.setReputationScore(model.getUserReputationScore());
singleUserProfileDisplay.setUserProfile(selectedUserIdentity.getUserProfile());
singleUserProfileDisplay.configureOpenProfileCard(selectedUserIdentity.getUserProfile());
singleUserProfileDisplay.setReputationScore(model.getUserReputationScore());
model.getUserProfiles().forEach(userProfileMenuItem ->
userProfileMenuItem.updateSelection(selectedUserIdentity.equals(userProfileMenuItem.getUserIdentity())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ void applySearchPredicate(String searchText) {
item.getRoleTypeString().toLowerCase().contains(string));
}

void openProfileCard(UserProfile userProfile) {
Navigation.navigateTo(NavigationTarget.PROFILE_CARD,
new ProfileCardController.InitData(userProfile));
void onOpenProfileCard(UserProfile userProfile) {
Navigation.navigateTo(NavigationTarget.PROFILE_CARD, new ProfileCardController.InitData(userProfile));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ protected void updateItem(BondedRolesListItem item, boolean empty) {
item.getUserProfile().ifPresent(userProfile -> {
userProfileIcon.setUserProfile(userProfile);
userProfileIcon.getStyleClass().add("hand-cursor");
userProfileIcon.setOnMouseClicked(e -> controller.openProfileCard(userProfile));
userName.setOnMouseClicked(e -> controller.openProfileCard(userProfile));
userName.setOnMouseClicked(e -> controller.onOpenProfileCard(userProfile));
});
setGraphic(hBox);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void onDeactivate() {
model.getListItems().clear();
}

void onShowDetails(UserProfile userProfile) {
void onOpenProfileCard(UserProfile userProfile) {
Navigation.navigateTo(NavigationTarget.PROFILE_CARD_REPUTATION,
new ProfileCardController.InitData(userProfile));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,9 @@ protected void updateItem(ListItem item, boolean empty) {
userProfileIcon.setUseSecondTick(false);
userProfileIcon.setUserProfile(item.getUserProfile());
userProfileIcon.getStyleClass().add("hand-cursor");
userProfileIcon.setOnMouseClicked(e -> controller.openProfileCard(item.getUserProfile()));
userName.setOnMouseClicked(e -> controller.openProfileCard(item.getUserProfile()));
setGraphic(hBox);
} else {
userProfileIcon.setOnMouseClicked(null);
userProfileIcon.dispose();
userName.setOnMouseClicked(null);
setGraphic(null);
Expand Down Expand Up @@ -292,7 +290,7 @@ protected void updateItem(ListItem item, boolean empty) {
super.updateItem(item, empty);

if (item != null && !empty) {
info.setOnAction(e -> controller.onShowDetails(item.getUserProfile()));
info.setOnAction(e -> controller.onOpenProfileCard(item.getUserProfile()));
setGraphic(info);
} else {
info.setOnAction(null);
Expand Down
Loading
Loading