Skip to content

Commit

Permalink
keep chatview listener open until ack, mailbox, or error
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacxx authored and ripcurlx committed Jul 23, 2021
1 parent 0cd20d6 commit 5cc3f86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void startAckTimer() {
this.setArrived(false);
this.setAckError(Res.get("support.errorTimeout"));
}
}, 5, TimeUnit.SECONDS);
}, 60, TimeUnit.SECONDS);
}

public ReadOnlyBooleanProperty acknowledgedProperty() {
Expand Down
21 changes: 11 additions & 10 deletions desktop/src/main/java/bisq/desktop/main/shared/ChatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class ChatView extends AnchorPane {
private ListChangeListener<ChatMessage> disputeDirectMessageListListener;
private Subscription inputTextAreaTextSubscription;
private final List<Attachment> tempAttachments = new ArrayList<>();
private ChangeListener<Boolean> storedInMailboxPropertyListener, arrivedPropertyListener;
private ChangeListener<Boolean> storedInMailboxPropertyListener, acknowledgedPropertyListener;
private ChangeListener<String> sendMessageErrorPropertyListener;

protected final CoinFormatter formatter;
Expand Down Expand Up @@ -483,6 +483,10 @@ private void updateMsgState(ChatMessage message) {
visible = true;
icon = AwesomeIcon.OK_SIGN;
text = Res.get("support.acknowledged");
} else if (message.storedInMailboxProperty().get()) {
visible = true;
icon = AwesomeIcon.ENVELOPE;
text = Res.get("support.savedInMailbox");
} else if (message.ackErrorProperty().get() != null) {
visible = true;
icon = AwesomeIcon.EXCLAMATION_SIGN;
Expand All @@ -493,10 +497,6 @@ private void updateMsgState(ChatMessage message) {
visible = true;
icon = AwesomeIcon.MAIL_REPLY;
text = Res.get("support.transient");
} else if (message.storedInMailboxProperty().get()) {
visible = true;
icon = AwesomeIcon.ENVELOPE;
text = Res.get("support.savedInMailbox");
} else {
visible = false;
log.debug("updateMsgState called but no msg state available. message={}", message);
Expand Down Expand Up @@ -598,7 +598,7 @@ private void onOpenAttachment(Attachment attachment) {

private void onSendMessage(String inputText) {
if (chatMessage != null) {
chatMessage.arrivedProperty().removeListener(arrivedPropertyListener);
chatMessage.acknowledgedProperty().removeListener(acknowledgedPropertyListener);
chatMessage.storedInMailboxProperty().removeListener(storedInMailboxPropertyListener);
chatMessage.sendMessageErrorProperty().removeListener(sendMessageErrorPropertyListener);
}
Expand All @@ -620,8 +620,9 @@ private void onSendMessage(String inputText) {
sendMsgBusyAnimation.play();
}, 500, TimeUnit.MILLISECONDS);

arrivedPropertyListener = (observable, oldValue, newValue) -> {
acknowledgedPropertyListener = (observable, oldValue, newValue) -> {
if (newValue) {
sendMsgInfoLabel.setVisible(false);
hideSendMsgInfo(timer);
}
};
Expand All @@ -642,7 +643,7 @@ private void onSendMessage(String inputText) {
}
};
if (chatMessage != null) {
chatMessage.arrivedProperty().addListener(arrivedPropertyListener);
chatMessage.acknowledgedProperty().addListener(acknowledgedPropertyListener);
chatMessage.storedInMailboxProperty().addListener(storedInMailboxPropertyListener);
chatMessage.sendMessageErrorProperty().addListener(sendMessageErrorPropertyListener);
}
Expand Down Expand Up @@ -715,8 +716,8 @@ private void removeListenersOnSessionChange() {
chatMessages.removeListener(disputeDirectMessageListListener);

if (chatMessage != null) {
if (arrivedPropertyListener != null)
chatMessage.arrivedProperty().removeListener(arrivedPropertyListener);
if (acknowledgedPropertyListener != null)
chatMessage.arrivedProperty().removeListener(acknowledgedPropertyListener);
if (storedInMailboxPropertyListener != null)
chatMessage.storedInMailboxProperty().removeListener(storedInMailboxPropertyListener);
}
Expand Down

0 comments on commit 5cc3f86

Please sign in to comment.