mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-03 17:40:10 +00:00
fix chat message listeners by returning source observable list (#830)
This commit is contained in:
parent
317aa2e72f
commit
3c7841ae28
3 changed files with 10 additions and 13 deletions
|
@ -394,6 +394,7 @@ public abstract class Trade implements Tradable, Model {
|
||||||
@Setter
|
@Setter
|
||||||
@Nullable
|
@Nullable
|
||||||
private String counterCurrencyTxId;
|
private String counterCurrencyTxId;
|
||||||
|
@Getter
|
||||||
private final ObservableList<ChatMessage> chatMessages = FXCollections.observableArrayList();
|
private final ObservableList<ChatMessage> chatMessages = FXCollections.observableArrayList();
|
||||||
|
|
||||||
// Transient
|
// Transient
|
||||||
|
@ -1666,12 +1667,6 @@ public abstract class Trade implements Tradable, Model {
|
||||||
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
|
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<ChatMessage> getChatMessages() {
|
|
||||||
synchronized (chatMessages) {
|
|
||||||
return FXCollections.observableArrayList(chatMessages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageState getPaymentSentMessageState() {
|
public MessageState getPaymentSentMessageState() {
|
||||||
if (isPaymentReceived()) return MessageState.ACKNOWLEDGED;
|
if (isPaymentReceived()) return MessageState.ACKNOWLEDGED;
|
||||||
if (processModel.getPaymentSentMessageStateProperty().get() == MessageState.ACKNOWLEDGED) return MessageState.ACKNOWLEDGED;
|
if (processModel.getPaymentSentMessageStateProperty().get() == MessageState.ACKNOWLEDGED) return MessageState.ACKNOWLEDGED;
|
||||||
|
|
|
@ -416,11 +416,13 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
||||||
private void updateNewChatMessagesByTradeMap() {
|
private void updateNewChatMessagesByTradeMap() {
|
||||||
model.dataModel.list.forEach(t -> {
|
model.dataModel.list.forEach(t -> {
|
||||||
Trade trade = t.getTrade();
|
Trade trade = t.getTrade();
|
||||||
newChatMessagesByTradeMap.put(trade.getId(),
|
synchronized (trade.getChatMessages()) {
|
||||||
trade.getChatMessages().stream()
|
newChatMessagesByTradeMap.put(trade.getId(),
|
||||||
.filter(m -> !m.isWasDisplayed())
|
trade.getChatMessages().stream()
|
||||||
.filter(m -> !m.isSystemMessage())
|
.filter(m -> !m.isWasDisplayed())
|
||||||
.count());
|
.filter(m -> !m.isSystemMessage())
|
||||||
|
.count());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,7 @@ public class ChatView extends AnchorPane {
|
||||||
copyIcon.getStyleClass().addAll("icon", "copy-icon-disputes");
|
copyIcon.getStyleClass().addAll("icon", "copy-icon-disputes");
|
||||||
|
|
||||||
// TODO There are still some cell rendering issues on updates
|
// TODO There are still some cell rendering issues on updates
|
||||||
setGraphic(messageAnchorPane);
|
UserThread.execute(() -> setGraphic(messageAnchorPane));
|
||||||
} else {
|
} else {
|
||||||
if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
|
if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
|
||||||
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
|
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
|
||||||
|
@ -448,7 +448,7 @@ public class ChatView extends AnchorPane {
|
||||||
|
|
||||||
copyIcon.setOnMouseClicked(null);
|
copyIcon.setOnMouseClicked(null);
|
||||||
messageLabel.setOnMouseClicked(null);
|
messageLabel.setOnMouseClicked(null);
|
||||||
setGraphic(null);
|
UserThread.execute(() -> setGraphic(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue