Skip to content

Commit

Permalink
Invalidate tablist footer only if match is running (#1313)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Herrera <[email protected]>
  • Loading branch information
Pablete1234 authored May 3, 2024
1 parent 4714177 commit 9e52762
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/src/main/java/tc/oc/pgm/tablist/MatchFooterTabEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,27 @@ public MatchFooterTabEntry(Match match) {
public void addToView(TabView view) {
super.addToView(view);
if (this.tickTask == null && match.isLoaded()) {
Runnable tick = MatchFooterTabEntry.this::invalidate;
Runnable tick =
new Runnable() {
private long length;
private boolean running;

@Override
public void run() {
long lastLen = length;
boolean lastRunning = running;
length = match.getDuration().getSeconds();
running = match.isRunning();

if (this.length != lastLen || this.running != lastRunning) {
MatchFooterTabEntry.this.invalidate();
}
}
};
this.tickTask =
match.getExecutor(MatchScope.LOADED).scheduleWithFixedDelay(tick, 0, 1, TimeUnit.SECONDS);
match
.getExecutor(MatchScope.LOADED)
.scheduleWithFixedDelay(tick, 0, 50, TimeUnit.MILLISECONDS);
}
}

Expand Down

0 comments on commit 9e52762

Please sign in to comment.