From 8475a5be09592f3852cfd96131e9833d5a73321f Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Mon, 13 Apr 2020 17:56:24 -0500 Subject: [PATCH] Fix an issue whereby the unread chat message count was not cleared properly The trader chat view can be opened either by clicking on the chat icon of a trade in the list, or clicking on "OPEN TRADER CHAT" button for the currently displayed trade. In the latter case, the count of new messages displayed on the chat icon was not cleared even though trader chat was shown. The solution is to move the scope of the routine that updates trader chat message count from within the table cell handler to the PendingTradesView class so that it can be called whenever onChat() is invoked (i.e. when the Trader Chat screen is shown). Clicking on the trader chat icon of a trade that is not selected should select that row in the trade list. It does not. This causes confusion as it gives misleading cues as to which trader you are communicating with. Issue a call to select the row of the button when clicked. Fixes #4172 --- .../pendingtrades/PendingTradesView.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java index 4f896caf334..7c0973d6bca 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java @@ -442,8 +442,26 @@ private void openChat(Trade trade) { // Delay display to next render frame to avoid that the popup is first quickly displayed in default position // and after a short moment in the correct position UserThread.execute(() -> chatPopupStage.setOpacity(1)); + updateChatMessageCount(trade, badgeByTrade.get(trade.getId())); } + private void updateChatMessageCount(Trade trade, JFXBadge badge) { + if (!trade.getId().equals(tradeIdOfOpenChat)) { + updateNewChatMessagesByTradeMap(); + long num = newChatMessagesByTradeMap.get(trade.getId()); + if (num > 0) { + badge.setText(String.valueOf(num)); + badge.setEnabled(true); + } else { + badge.setText(""); + badge.setEnabled(false); + } + } else { + badge.setText(""); + badge.setEnabled(false); + } + badge.refreshBadge(); + } /////////////////////////////////////////////////////////////////////////////////////////// // Private @@ -729,17 +747,17 @@ public void updateItem(final PendingTradesListItem newItem, boolean empty) { } button.setOnAction(e -> { + tableView.getSelectionModel().select(this.getIndex()); openChat(trade); - update(trade, badge); }); if (!listenerByTrade.containsKey(id)) { - ListChangeListener listener = c -> update(trade, badge); + ListChangeListener listener = c -> updateChatMessageCount(trade, badge); listenerByTrade.put(id, listener); trade.getChatMessages().addListener(listener); } - update(trade, badge); + updateChatMessageCount(trade, badge); setGraphic(badge); } else { @@ -747,23 +765,6 @@ public void updateItem(final PendingTradesListItem newItem, boolean empty) { } } - private void update(Trade trade, JFXBadge badge) { - if (!trade.getId().equals(tradeIdOfOpenChat)) { - updateNewChatMessagesByTradeMap(); - long num = newChatMessagesByTradeMap.get(trade.getId()); - if (num > 0) { - badge.setText(String.valueOf(num)); - badge.setEnabled(true); - } else { - badge.setText(""); - badge.setEnabled(false); - } - } else { - badge.setText(""); - badge.setEnabled(false); - } - badge.refreshBadge(); - } }; } });