mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +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);
|
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
|
// PROTO BUFFER
|
||||||
|
|
|
@ -22,6 +22,7 @@ import bisq.core.arbitration.messages.DisputeMessage;
|
||||||
import bisq.core.arbitration.messages.DisputeResultMessage;
|
import bisq.core.arbitration.messages.DisputeResultMessage;
|
||||||
import bisq.core.chat.ChatManager;
|
import bisq.core.chat.ChatManager;
|
||||||
import bisq.core.chat.ChatSession;
|
import bisq.core.chat.ChatSession;
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
import bisq.network.p2p.NodeAddress;
|
import bisq.network.p2p.NodeAddress;
|
||||||
|
|
||||||
|
@ -181,13 +182,33 @@ public class TradeChatSession extends ChatSession {
|
||||||
public void storeDisputeCommunicationMessage(DisputeCommunicationMessage message) {
|
public void storeDisputeCommunicationMessage(DisputeCommunicationMessage message) {
|
||||||
Optional<Trade> tradeOptional = tradeManager.getTradeById(message.getTradeId());
|
Optional<Trade> tradeOptional = tradeManager.getTradeById(message.getTradeId());
|
||||||
if (tradeOptional.isPresent()) {
|
if (tradeOptional.isPresent()) {
|
||||||
if (tradeOptional.get().getCommunicationMessages().stream()
|
Trade trade = tradeOptional.get();
|
||||||
.noneMatch(m -> m.getUid().equals(message.getUid()))) {
|
ObservableList<DisputeCommunicationMessage> communicationMessages = trade.getCommunicationMessages();
|
||||||
tradeOptional.get().addCommunicationMessage(message);
|
if (communicationMessages.stream().noneMatch(m -> m.getUid().equals(message.getUid()))) {
|
||||||
|
if (communicationMessages.isEmpty()) {
|
||||||
|
addSystemMsg(trade);
|
||||||
|
}
|
||||||
|
trade.addCommunicationMessage(message);
|
||||||
} else {
|
} else {
|
||||||
log.warn("Trade got a disputeCommunicationMessage what we have already stored. UId = {} TradeId = {}",
|
log.warn("Trade got a disputeCommunicationMessage what we have already stored. UId = {} TradeId = {}",
|
||||||
message.getUid(), message.getTradeId());
|
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 -> {
|
model.dataModel.list.forEach(t -> {
|
||||||
Trade trade = t.getTrade();
|
Trade trade = t.getTrade();
|
||||||
newChatMessagesByTradeMap.put(trade.getId(),
|
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();
|
chatPopupStage.close();
|
||||||
|
|
||||||
if (trade.getCommunicationMessages().isEmpty()) {
|
if (trade.getCommunicationMessages().isEmpty()) {
|
||||||
DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(
|
((TradeChatSession) model.dataModel.tradeManager.getChatManager().getChatSession()).addSystemMsg(trade);
|
||||||
DisputeCommunicationMessage.Type.TRADE,
|
|
||||||
trade.getId(),
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
Res.get("tradeChat.rules"),
|
|
||||||
new NodeAddress("null:0000")
|
|
||||||
);
|
|
||||||
disputeCommunicationMessage.setSystemMessage(true);
|
|
||||||
trade.getCommunicationMessages().add(disputeCommunicationMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trade.getCommunicationMessages().forEach(m -> m.setWasDisplayed(true));
|
trade.getCommunicationMessages().forEach(m -> m.setWasDisplayed(true));
|
||||||
|
|
Loading…
Add table
Reference in a new issue