From 41067b23bbd60aa69093ee53692ae317841ffacb Mon Sep 17 00:00:00 2001 From: fipwmaqzufheoxq92ebc <29818044+fipwmaqzufheoxq92ebc@users.noreply.github.com> Date: Sun, 11 Oct 2020 12:12:40 +0200 Subject: [PATCH] Fixes #958: Disable auto-reload of equipments-page. --- public/js/grocy_dbchangedhandling.js | 39 +++++++++++++++------------- views/equipment.blade.php | 1 + views/layout/default.blade.php | 3 ++- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/public/js/grocy_dbchangedhandling.js b/public/js/grocy_dbchangedhandling.js index 77ee6c0c..c6780825 100644 --- a/public/js/grocy_dbchangedhandling.js +++ b/public/js/grocy_dbchangedhandling.js @@ -15,31 +15,34 @@ // Check if the database has changed once a minute // If a change is detected, reload the current page, but only if already idling for at least 50 seconds, // when there is no unsaved form data and when the user enabled auto reloading -setInterval(function() +if(DbChangHandlingEnabled) { - Grocy.Api.Get('system/db-changed-time', - function(result) - { - var newDbChangedTime = moment(result.changed_time); - if (newDbChangedTime.isAfter(Grocy.DatabaseChangedTime)) + setInterval(function() + { + Grocy.Api.Get('system/db-changed-time', + function(result) { - if (Grocy.IdleTime >= 50) + var newDbChangedTime = moment(result.changed_time); + if (newDbChangedTime.isAfter(Grocy.DatabaseChangedTime)) { - if (BoolVal(Grocy.UserSettings.auto_reload_on_db_change) && $("form.is-dirty").length === 0 && !$("body").hasClass("fullscreen-card")) + if (Grocy.IdleTime >= 50) { - window.location.reload(); + if (BoolVal(Grocy.UserSettings.auto_reload_on_db_change) && $("form.is-dirty").length === 0 && !$("body").hasClass("fullscreen-card")) + { + window.location.reload(); + } } - } - Grocy.DatabaseChangedTime = newDbChangedTime; + Grocy.DatabaseChangedTime = newDbChangedTime; + } + }, + function(xhr) + { + console.error(xhr); } - }, - function(xhr) - { - console.error(xhr); - } - ); -}, 60000); + ); + }, 60000); +} Grocy.IdleTime = 0; Grocy.ResetIdleTime = function() diff --git a/views/equipment.blade.php b/views/equipment.blade.php index 8fe28532..811b9bfb 100644 --- a/views/equipment.blade.php +++ b/views/equipment.blade.php @@ -3,6 +3,7 @@ @section('title', $__t('Equipment')) @section('activeNav', 'equipment') @section('viewJsName', 'equipment') +@section('DbChangHandlingEnabled', 'false') @section('content')