From 9349e3341fb55e945ff10fc233e9bb1521c792e0 Mon Sep 17 00:00:00 2001 From: Fredrik Borg Date: Tue, 25 May 2021 10:56:21 +0200 Subject: [PATCH] call poll method immediately on focus --- django_unicorn/static/js/component.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/django_unicorn/static/js/component.js b/django_unicorn/static/js/component.js index 775466a3..13b40110 100644 --- a/django_unicorn/static/js/component.js +++ b/django_unicorn/static/js/component.js @@ -328,6 +328,15 @@ export class Component { clearInterval(this.poll.timer); } } else { + // tab gets focus -> call poll method once and + // start polling at intervals + if (this.isPollEnabled()) { + this.callMethod( + this.poll.method, + this.poll.partials, + this.handlePollError + ); + } this.startPolling(); } },