mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 06:55:08 +01:00
Merge pull request #3170 from chimp1984/Fix-bug-with-missing-chat-systemMsg
Fix bug with not showing system msg at peer who receives msg
This commit is contained in:
commit
0a12676946
3 changed files with 54 additions and 14 deletions
|
@ -128,6 +128,31 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
|
|||
false);
|
||||
}
|
||||
|
||||
public DisputeCommunicationMessage(DisputeCommunicationMessage.Type type,
|
||||
String tradeId,
|
||||
int traderId,
|
||||
boolean senderIsTrader,
|
||||
String message,
|
||||
NodeAddress senderNodeAddress,
|
||||
long date) {
|
||||
this(type,
|
||||
tradeId,
|
||||
traderId,
|
||||
senderIsTrader,
|
||||
message,
|
||||
null,
|
||||
senderNodeAddress,
|
||||
date,
|
||||
false,
|
||||
false,
|
||||
UUID.randomUUID().toString(),
|
||||
Version.getP2PMessageVersion(),
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.core.arbitration.messages.DisputeMessage;
|
|||
import bisq.core.arbitration.messages.DisputeResultMessage;
|
||||
import bisq.core.chat.ChatManager;
|
||||
import bisq.core.chat.ChatSession;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
|
||||
|
@ -181,13 +182,33 @@ public class TradeChatSession extends ChatSession {
|
|||
public void storeDisputeCommunicationMessage(DisputeCommunicationMessage message) {
|
||||
Optional<Trade> tradeOptional = tradeManager.getTradeById(message.getTradeId());
|
||||
if (tradeOptional.isPresent()) {
|
||||
if (tradeOptional.get().getCommunicationMessages().stream()
|
||||
.noneMatch(m -> m.getUid().equals(message.getUid()))) {
|
||||
tradeOptional.get().addCommunicationMessage(message);
|
||||
Trade trade = tradeOptional.get();
|
||||
ObservableList<DisputeCommunicationMessage> communicationMessages = trade.getCommunicationMessages();
|
||||
if (communicationMessages.stream().noneMatch(m -> m.getUid().equals(message.getUid()))) {
|
||||
if (communicationMessages.isEmpty()) {
|
||||
addSystemMsg(trade);
|
||||
}
|
||||
trade.addCommunicationMessage(message);
|
||||
} else {
|
||||
log.warn("Trade got a disputeCommunicationMessage what we have already stored. UId = {} TradeId = {}",
|
||||
message.getUid(), message.getTradeId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addSystemMsg(Trade trade) {
|
||||
// We need to use the trade date as otherwise our system msg would not be displayed first as the list is sorted
|
||||
// by date.
|
||||
DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(
|
||||
DisputeCommunicationMessage.Type.TRADE,
|
||||
trade.getId(),
|
||||
0,
|
||||
false,
|
||||
Res.get("tradeChat.rules"),
|
||||
new NodeAddress("null:0000"),
|
||||
trade.getDate().getTime()
|
||||
);
|
||||
disputeCommunicationMessage.setSystemMessage(true);
|
||||
trade.getCommunicationMessages().add(disputeCommunicationMessage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,7 +317,10 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
model.dataModel.list.forEach(t -> {
|
||||
Trade trade = t.getTrade();
|
||||
newChatMessagesByTradeMap.put(trade.getId(),
|
||||
trade.getCommunicationMessages().stream().filter(m -> !m.isWasDisplayed()).count());
|
||||
trade.getCommunicationMessages().stream()
|
||||
.filter(m -> !m.isWasDisplayed())
|
||||
.filter(m -> !m.isSystemMessage())
|
||||
.count());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -326,16 +329,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
chatPopupStage.close();
|
||||
|
||||
if (trade.getCommunicationMessages().isEmpty()) {
|
||||
DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(
|
||||
DisputeCommunicationMessage.Type.TRADE,
|
||||
trade.getId(),
|
||||
0,
|
||||
false,
|
||||
Res.get("tradeChat.rules"),
|
||||
new NodeAddress("null:0000")
|
||||
);
|
||||
disputeCommunicationMessage.setSystemMessage(true);
|
||||
trade.getCommunicationMessages().add(disputeCommunicationMessage);
|
||||
((TradeChatSession) model.dataModel.tradeManager.getChatManager().getChatSession()).addSystemMsg(trade);
|
||||
}
|
||||
|
||||
trade.getCommunicationMessages().forEach(m -> m.setWasDisplayed(true));
|
||||
|
|
Loading…
Add table
Reference in a new issue