Skip to content

Commit

Permalink
Merge pull request bisq-network#2256 from axpoems/remove-model-chat-msg
Browse files Browse the repository at this point in the history
Remove model dependency from chat message box classes
  • Loading branch information
djing-chan authored Jun 11, 2024
2 parents 116b9f8 + e1b7179 commit 869e05b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
import bisq.chat.ChatMessage;
import bisq.desktop.main.content.bisq_easy.open_trades.MyProtocolLogMessageBox;
import bisq.desktop.main.content.bisq_easy.open_trades.PeerProtocolLogMessageBox;
import bisq.desktop.main.content.chat.message_container.list.message_box.*;
import bisq.desktop.main.content.chat.message_container.list.message_box.LeaveChatMessageBox;
import bisq.desktop.main.content.chat.message_container.list.message_box.MessageBox;
import bisq.desktop.main.content.chat.message_container.list.message_box.MyOfferMessageBox;
import bisq.desktop.main.content.chat.message_container.list.message_box.MyTextMessageBox;
import bisq.desktop.main.content.chat.message_container.list.message_box.PeerOfferMessageBox;
import bisq.desktop.main.content.chat.message_container.list.message_box.PeerTextMessageBox;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
Expand All @@ -38,11 +43,9 @@ final class ChatMessageListCellFactory
implements Callback<ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>>,
ListCell<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>>> {
private final ChatMessagesListController controller;
private final ChatMessagesListModel model;

public ChatMessageListCellFactory(ChatMessagesListController controller, ChatMessagesListModel model) {
public ChatMessageListCellFactory(ChatMessagesListController controller) {
this.controller = controller;
this.model = model;
}

@Override
Expand Down Expand Up @@ -133,16 +136,16 @@ private MessageBox createMessage(ChatMessageListItem<? extends ChatMessage, ? ex
return new MyProtocolLogMessageBox(item, controller);
} else {
return item.isBisqEasyPublicChatMessageWithOffer()
? new MyOfferMessageBox(item, list, controller, model)
: new MyTextMessageBox(item, list, controller, model);
? new MyOfferMessageBox(item, list, controller)
: new MyTextMessageBox(item, list, controller);
}
} else {
if (item.isProtocolLogMessage()) {
return new PeerProtocolLogMessageBox(item);
} else {
return item.isBisqEasyPublicChatMessageWithOffer()
? new PeerOfferMessageBox(item, list, controller, model)
: new PeerTextMessageBox(item, list, controller, model);
? new PeerOfferMessageBox(item, list, controller)
: new PeerTextMessageBox(item, list, controller);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ChatMessagesListView(ChatMessagesListModel model, ChatMessagesListControl
VBox placeholder = ChatUtil.createEmptyChatPlaceholder(placeholderTitle, placeholderDescription);
listView.setPlaceholder(placeholder);

listView.setCellFactory(new ChatMessageListCellFactory(controller, model));
listView.setCellFactory(new ChatMessageListCellFactory(controller));

// https://stackoverflow.com/questions/20621752/javafx-make-listview-not-selectable-via-mouse
listView.setSelectionModel(new NoSelectionModel<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import bisq.desktop.components.controls.DropdownMenu;
import bisq.desktop.main.content.chat.message_container.list.ChatMessageListItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListController;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListModel;
import bisq.desktop.main.content.components.UserProfileIcon;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.geometry.Insets;
Expand All @@ -55,7 +54,6 @@ public abstract class BubbleMessageBox extends MessageBox {
protected final ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>> item;
protected final ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> list;
protected final ChatMessagesListController controller;
protected final ChatMessagesListModel model;
protected final UserProfileIcon userProfileIcon = new UserProfileIcon(60);
protected final HBox reactionsHBox = new HBox(20);
protected final VBox quotedMessageVBox, contentVBox;
Expand All @@ -66,12 +64,10 @@ public abstract class BubbleMessageBox extends MessageBox {

public BubbleMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>> item,
ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> list,
ChatMessagesListController controller,
ChatMessagesListModel model) {
ChatMessagesListController controller) {
this.item = item;
this.list = list;
this.controller = controller;
this.model = model;

setUpUserNameAndDateTime();
setUpUserProfileIcon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import bisq.desktop.components.controls.DropdownMenuItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessageListItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListController;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListModel;
import bisq.i18n.Res;
import bisq.offer.Direction;
import de.jensd.fx.fontawesome.AwesomeIcon;
Expand All @@ -47,8 +46,8 @@ public final class MyOfferMessageBox extends BubbleMessageBox {

public MyOfferMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>> item,
ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> list,
ChatMessagesListController controller, ChatMessagesListModel model) {
super(item, list, controller, model);
ChatMessagesListController controller) {
super(item, list, controller);

// User profile icon
userProfileIcon.setSize(OFFER_MESSAGE_USER_ICON_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import bisq.desktop.components.controls.BisqTooltip;
import bisq.desktop.main.content.chat.message_container.list.ChatMessageListItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListController;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListModel;
import bisq.i18n.Res;
import bisq.network.p2p.services.confidential.ack.MessageDeliveryStatus;
import de.jensd.fx.fontawesome.AwesomeDude;
Expand Down Expand Up @@ -56,8 +55,8 @@ public final class MyTextMessageBox extends BubbleMessageBox {

public MyTextMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>> item,
ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> list,
ChatMessagesListController controller, ChatMessagesListModel model) {
super(item, list, controller, model);
ChatMessagesListController controller) {
super(item, list, controller);

quotedMessageVBox.setId("chat-message-quote-box-my-msg");
setUpEditFunctionality();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import bisq.desktop.components.containers.Spacer;
import bisq.desktop.main.content.chat.message_container.list.ChatMessageListItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListController;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListModel;
import bisq.i18n.Res;
import bisq.offer.Direction;
import javafx.geometry.Insets;
Expand All @@ -46,8 +45,8 @@ public final class PeerOfferMessageBox extends PeerTextMessageBox {

public PeerOfferMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>> item,
ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> list,
ChatMessagesListController controller, ChatMessagesListModel model) {
super(item, list, controller, model);
ChatMessagesListController controller) {
super(item, list, controller);

HBox.setMargin(copyIcon, new Insets(4, 0, -4, 0));
HBox.setMargin(supportedLanguages, new Insets(5, 0, -5, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import bisq.desktop.components.controls.DropdownMenuItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessageListItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListController;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListModel;
import bisq.i18n.Res;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.geometry.Insets;
Expand All @@ -44,8 +43,8 @@ public class PeerTextMessageBox extends BubbleMessageBox {

public PeerTextMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>> item,
ListView<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> list,
ChatMessagesListController controller, ChatMessagesListModel model) {
super(item, list, controller, model);
ChatMessagesListController controller) {
super(item, list, controller);

setUpPeerMessage();
setMargin(userNameAndDateHBox, new Insets(-5, 0, -5, 10));
Expand Down

0 comments on commit 869e05b

Please sign in to comment.