Skip to content

Commit

Permalink
Fix line refresh
Browse files Browse the repository at this point in the history
Recycling was wrong in some cases.
  • Loading branch information
zapek committed Nov 13, 2023
1 parent 03336f9 commit 23d1c02
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ui/src/main/java/io/xeres/ui/custom/ChatListCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ChatListCell implements Cell<ChatLine, TextFlow>
private final TextFlow content;
private final Label time;
private final Label action;
private boolean isComplex;
private boolean isRich;

public ChatListCell(ChatLine line)
{
Expand All @@ -73,27 +73,28 @@ public TextFlow getNode()
@Override
public boolean isReusable()
{
return !isComplex;
return !isRich;
}

@Override
public void reset()
{
if (isReusable())
{
content.getChildren().remove(2);
content.getChildren().remove(2); // keep time and action only
}
}

@Override
public void updateItem(ChatLine line)
{
isComplex = line.isRich();
isRich = line.isRich();

time.setText(formatter.format(line.getInstant()));

action.setText(line.getAction());
var nicknameColor = line.getNicknameColor();
action.getStyleClass().removeAll(allColors);
var nicknameColor = line.getNicknameColor();
if (nicknameColor != null)
{
action.getStyleClass().add(nicknameColor);
Expand All @@ -103,10 +104,7 @@ public void updateItem(ChatLine line)
.map(Content::getNode)
.toList();

if (!isComplex)
{
content.pseudoClassStateChanged(passivePseudoClass, !line.isActiveAction());
}
content.pseudoClassStateChanged(passivePseudoClass, !line.isActiveAction());

content.getChildren().addAll(nodes);
}
Expand Down

0 comments on commit 23d1c02

Please sign in to comment.