From 309955376f5fa6eea37a9af3de1a61dbaf2e055f Mon Sep 17 00:00:00 2001 From: Anna Belova Date: Mon, 14 Jun 2021 10:47:45 +0300 Subject: [PATCH] Should fix when the device is in sleep mode Hello. I have a problem when my laptop is in sleep, after waking up I see an error connecting to the Internet. I found out that when this condition is met, my page starts to reload, but since the laptop is in sleep mode, then it does not have access to the Internet, respectively. I found a solution to this problem in correcting this part of the code When I added setTimeout I stopped getting infinite page reload and further connection error. Now my page reloads when my laptop wakes up. --- resources/views/script.blade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/script.blade.php b/resources/views/script.blade.php index 77d61fd..be9dab7 100644 --- a/resources/views/script.blade.php +++ b/resources/views/script.blade.php @@ -27,7 +27,9 @@ if ({{ $ageCheckInterval }} > 0) { setInterval(function () { if (new Date() - lastCheck >= {{ $ageCheckInterval + $ageThreshold }}) { - location.reload(true); + setTimeout(function () { + location.reload(true); + }, Math.max(0, {{ $ageCheckInterval }} - 500) ) } }, {{ $ageCheckInterval }}); }