From 785e1b323c63f825ba94b4dd9b9e4b976bc8cc33 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 28 Jul 2017 05:48:34 +0200 Subject: [PATCH] refresh-data - make guard condition better readable --- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index beb1b75bb7..3a7f448309 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -323,9 +323,10 @@ public class ComboPlugin implements PluginBase, PumpInterface { return; } - if (!reason.toLowerCase().contains("user") - && lastCmdTime.getTime() > 0 - && System.currentTimeMillis() < lastCmdTime.getTime() + 60 * 1000) { + boolean notAUserRequest = !reason.toLowerCase().contains("user"); + boolean wasRunAtLeastOnce = lastCmdTime.getTime() > 0; + boolean ranWithinTheLastMinute = System.currentTimeMillis() < lastCmdTime.getTime() + 60 * 1000; + if (notAUserRequest && wasRunAtLeastOnce && ranWithinTheLastMinute) { log.debug("Not fetching state from pump, since we did already within the last 60 seconds"); } else { runCommand(new ReadPumpStateCommand());