From 9e52762d0741fcfdc5e650e9cdcb1832cc16ff7b Mon Sep 17 00:00:00 2001 From: Pablo Herrera Date: Fri, 3 May 2024 19:39:29 +0200 Subject: [PATCH] Invalidate tablist footer only if match is running (#1313) Signed-off-by: Pablo Herrera --- .../oc/pgm/tablist/MatchFooterTabEntry.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/tablist/MatchFooterTabEntry.java b/core/src/main/java/tc/oc/pgm/tablist/MatchFooterTabEntry.java index c931764271..22d42b1b85 100644 --- a/core/src/main/java/tc/oc/pgm/tablist/MatchFooterTabEntry.java +++ b/core/src/main/java/tc/oc/pgm/tablist/MatchFooterTabEntry.java @@ -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); } }