Skip to content

Commit

Permalink
Merge pull request #5551 from jmacxx/chat_msg_ack
Browse files Browse the repository at this point in the history
Improve Chat message reliability
  • Loading branch information
ripcurlx authored Jun 17, 2021
2 parents ddd2ab4 + e75a4ef commit 1a59e92
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions core/src/main/java/bisq/core/support/messages/ChatMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

package bisq.core.support.messages;

import bisq.core.locale.Res;
import bisq.core.support.SupportType;
import bisq.core.support.dispute.Attachment;
import bisq.core.support.dispute.Dispute;
import bisq.core.support.dispute.DisputeResult;

import bisq.network.p2p.NodeAddress;

import bisq.common.UserThread;
import bisq.common.app.Version;
import bisq.common.util.Utilities;

Expand Down Expand Up @@ -297,6 +299,16 @@ public void setAcknowledged(boolean acknowledged) {
notifyChangeListener();
}

// each chat message notifies the user if an ACK is not received in time
public void startAckTimer() {
UserThread.runAfter(() -> {
if (!this.getAcknowledgedProperty().get()) {
this.setArrived(false);
this.setAckError(Res.get("support.errorTimeout"));
}
}, 5, TimeUnit.SECONDS);
}

public ReadOnlyBooleanProperty acknowledgedProperty() {
return acknowledgedProperty;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,10 @@ support.closeTicket=Close ticket
support.attachments=Attachments:
support.savedInMailbox=Message saved in receiver's mailbox
support.arrived=Message arrived at receiver
support.transient=Message is on its way to receiver
support.acknowledged=Message arrival confirmed by receiver
support.error=Receiver could not process message. Error: {0}
support.errorTimeout=timed out. Try sending message again.
support.buyerAddress=BTC buyer address
support.sellerAddress=BTC seller address
support.role=Role
Expand Down
6 changes: 4 additions & 2 deletions desktop/src/main/java/bisq/desktop/main/shared/ChatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ private void updateMsgState(ChatMessage message) {
statusInfoLabel.getStyleClass().add("error-text");
} else if (message.arrivedProperty().get()) {
visible = true;
icon = AwesomeIcon.OK;
text = Res.get("support.arrived");
icon = AwesomeIcon.MAIL_REPLY;
text = Res.get("support.transient");
} else if (message.storedInMailboxProperty().get()) {
visible = true;
icon = AwesomeIcon.ENVELOPE;
Expand Down Expand Up @@ -610,6 +610,8 @@ private void onSendMessage(String inputText) {
inputTextArea.setDisable(true);
inputTextArea.clear();

chatMessage.startAckTimer();

Timer timer = UserThread.runAfter(() -> {
sendMsgInfoLabel.setVisible(true);
sendMsgInfoLabel.setManaged(true);
Expand Down

0 comments on commit 1a59e92

Please sign in to comment.