mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
Fix chat view memory leak (#829)
This commit is contained in:
parent
5c36b00d07
commit
317aa2e72f
1 changed files with 8 additions and 4 deletions
|
@ -407,7 +407,7 @@ public class ChatView extends AnchorPane {
|
||||||
attachmentsBox.getChildren().clear();
|
attachmentsBox.getChildren().clear();
|
||||||
if (allowAttachments &&
|
if (allowAttachments &&
|
||||||
message.getAttachments() != null &&
|
message.getAttachments() != null &&
|
||||||
message.getAttachments().size() > 0) {
|
!message.getAttachments().isEmpty()) {
|
||||||
AnchorPane.setBottomAnchor(messageLabel, bottomBorder + attachmentsBoxHeight + 10);
|
AnchorPane.setBottomAnchor(messageLabel, bottomBorder + attachmentsBoxHeight + 10);
|
||||||
attachmentsBox.getChildren().add(new AutoTooltipLabel(Res.get("support.attachments") + " ") {{
|
attachmentsBox.getChildren().add(new AutoTooltipLabel(Res.get("support.attachments") + " ") {{
|
||||||
setPadding(new Insets(0, 0, 3, 0));
|
setPadding(new Insets(0, 0, 3, 0));
|
||||||
|
@ -662,8 +662,12 @@ public class ChatView extends AnchorPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToBottom() {
|
public void scrollToBottom() {
|
||||||
if (messageListView != null)
|
UserThread.execute(() -> {
|
||||||
UserThread.execute(() -> messageListView.scrollTo(Integer.MAX_VALUE));
|
if (messageListView != null && !messageListView.getItems().isEmpty()) {
|
||||||
|
int lastIndex = messageListView.getItems().size();
|
||||||
|
messageListView.scrollTo(lastIndex);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInputBoxVisible(boolean visible) {
|
public void setInputBoxVisible(boolean visible) {
|
||||||
|
@ -695,7 +699,7 @@ public class ChatView extends AnchorPane {
|
||||||
private void removeListenersOnSessionChange() {
|
private void removeListenersOnSessionChange() {
|
||||||
if (chatMessages != null) {
|
if (chatMessages != null) {
|
||||||
if (disputeDirectMessageListListener != null) chatMessages.removeListener(disputeDirectMessageListListener);
|
if (disputeDirectMessageListListener != null) chatMessages.removeListener(disputeDirectMessageListListener);
|
||||||
chatMessages.forEach(msg -> msg.removeChangeListener());
|
chatMessages.forEach(ChatMessage::removeChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatMessage != null) {
|
if (chatMessage != null) {
|
||||||
|
|
Loading…
Reference in a new issue