mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-28 00:39:31 -05:00
update chat view messages on user thread
This commit is contained in:
parent
2e605a590e
commit
3fbb2f95d0
@ -299,6 +299,7 @@ public class ChatView extends AnchorPane {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(ChatMessage message, boolean empty) {
|
protected void updateItem(ChatMessage message, boolean empty) {
|
||||||
|
UserThread.execute(() -> {
|
||||||
super.updateItem(message, empty);
|
super.updateItem(message, empty);
|
||||||
if (message != null && !empty) {
|
if (message != null && !empty) {
|
||||||
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(messageLabel.getText()));
|
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(messageLabel.getText()));
|
||||||
@ -346,7 +347,7 @@ public class ChatView extends AnchorPane {
|
|||||||
bg.setId("message-bubble-green");
|
bg.setId("message-bubble-green");
|
||||||
messageLabel.getStyleClass().add("my-message");
|
messageLabel.getStyleClass().add("my-message");
|
||||||
copyIcon.getStyleClass().add("my-message");
|
copyIcon.getStyleClass().add("my-message");
|
||||||
message.addWeakMessageStateListener(() -> updateMsgState(message));
|
message.addWeakMessageStateListener(() -> UserThread.execute(() -> updateMsgState(message)));
|
||||||
updateMsgState(message);
|
updateMsgState(message);
|
||||||
} else if (isMyMsg) {
|
} else if (isMyMsg) {
|
||||||
headerLabel.getStyleClass().add("my-message-header");
|
headerLabel.getStyleClass().add("my-message-header");
|
||||||
@ -363,11 +364,11 @@ public class ChatView extends AnchorPane {
|
|||||||
|
|
||||||
sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> {
|
sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> {
|
||||||
if (!newValue)
|
if (!newValue)
|
||||||
updateMsgState(message);
|
UserThread.execute(() -> updateMsgState(message));
|
||||||
};
|
};
|
||||||
|
|
||||||
sendMsgBusyAnimation.isRunningProperty().addListener(sendMsgBusyAnimationListener);
|
sendMsgBusyAnimation.isRunningProperty().addListener(sendMsgBusyAnimationListener);
|
||||||
message.addWeakMessageStateListener(() -> updateMsgState(message));
|
message.addWeakMessageStateListener(() -> UserThread.execute(() -> updateMsgState(message)));
|
||||||
updateMsgState(message);
|
updateMsgState(message);
|
||||||
} else {
|
} else {
|
||||||
headerLabel.getStyleClass().add("message-header");
|
headerLabel.getStyleClass().add("message-header");
|
||||||
@ -456,7 +457,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
|
||||||
UserThread.execute(() -> setGraphic(messageAnchorPane));
|
setGraphic(messageAnchorPane);
|
||||||
} else {
|
} else {
|
||||||
if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
|
if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
|
||||||
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
|
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
|
||||||
@ -465,12 +466,12 @@ public class ChatView extends AnchorPane {
|
|||||||
|
|
||||||
copyIcon.setOnMouseClicked(null);
|
copyIcon.setOnMouseClicked(null);
|
||||||
messageLabel.setOnMouseClicked(null);
|
messageLabel.setOnMouseClicked(null);
|
||||||
UserThread.execute(() -> setGraphic(null));
|
setGraphic(null);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMsgState(ChatMessage message) {
|
private void updateMsgState(ChatMessage message) {
|
||||||
UserThread.execute(() -> {
|
|
||||||
boolean visible;
|
boolean visible;
|
||||||
AwesomeIcon icon = null;
|
AwesomeIcon icon = null;
|
||||||
String text = null;
|
String text = null;
|
||||||
@ -508,7 +509,6 @@ public class ChatView extends AnchorPane {
|
|||||||
statusIcon.setTooltip(new Tooltip(text));
|
statusIcon.setTooltip(new Tooltip(text));
|
||||||
statusInfoLabel.setText(text);
|
statusInfoLabel.setText(text);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user