From 8e28d47a2da8be00c834912102e7adadaf18bedf Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Tue, 3 Oct 2023 11:43:21 -0600 Subject: [PATCH 1/7] add await to forceTransition process there was an issue with the alert, which was showing a promise object rather than the actual result. This change works to resolve that issue --- www/js/control/ControlCollectionHelper.tsx | 2 +- www/js/control/ProfileSettings.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/js/control/ControlCollectionHelper.tsx b/www/js/control/ControlCollectionHelper.tsx index 99318b1ac..d94f12448 100644 --- a/www/js/control/ControlCollectionHelper.tsx +++ b/www/js/control/ControlCollectionHelper.tsx @@ -21,7 +21,7 @@ type collectionConfig = { export async function forceTransition(transition) { try { - let result = forceTransitionWrapper(transition); + let result = await forceTransitionWrapper(transition); window.alert('success -> '+result); } catch (err) { window.alert('error -> '+err); diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 8035c9462..5f4347e21 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -252,7 +252,7 @@ const ProfileSettings = () => { async function userStartStopTracking() { const transitionToForce = collectSettings.trackingOn ? 'STOP_TRACKING' : 'START_TRACKING'; - forceTransition(transitionToForce); + await forceTransition(transitionToForce); refreshCollectSettings(); } From cd8b3833412874d19a17e8d505b32830d024693f Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 4 Oct 2023 14:37:43 -0600 Subject: [PATCH 2/7] rename component --- www/js/control/ControlCollectionHelper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/js/control/ControlCollectionHelper.tsx b/www/js/control/ControlCollectionHelper.tsx index d94f12448..29f175a06 100644 --- a/www/js/control/ControlCollectionHelper.tsx +++ b/www/js/control/ControlCollectionHelper.tsx @@ -132,7 +132,7 @@ const formatConfigForDisplay = function(config, accuracyOptions) { return retVal; } -const ControlSyncHelper = ({ editVis, setEditVis }) => { +const ControlCollectionHelper = ({ editVis, setEditVis }) => { const {colors} = useTheme(); const Logger = getAngularService("Logger"); @@ -282,4 +282,4 @@ const ControlSyncHelper = ({ editVis, setEditVis }) => { ); }; -export default ControlSyncHelper; +export default ControlCollectionHelper; From 877f8cb1c4d9c7bdde11ab1b0ac72950c101248f Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 4 Oct 2023 14:38:22 -0600 Subject: [PATCH 3/7] move closing modal to reload function trying to ensure that the updates are complete by moving anything that happens after into the same function, after the await --- www/js/control/ControlCollectionHelper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/js/control/ControlCollectionHelper.tsx b/www/js/control/ControlCollectionHelper.tsx index 29f175a06..fe6821f4b 100644 --- a/www/js/control/ControlCollectionHelper.tsx +++ b/www/js/control/ControlCollectionHelper.tsx @@ -172,6 +172,7 @@ const ControlCollectionHelper = ({ editVis, setEditVis }) => { console.log("new config = ", localConfig); try{ let set = await setConfig(localConfig); + setEditVis(false); //TODO find way to not need control.update.complete event broadcast } catch(err) { Logger.displayError("Error while setting collection config", err); @@ -268,8 +269,7 @@ const ControlCollectionHelper = ({ editVis, setEditVis }) => { {geofenceComponent} - From 304ceaa84fcbfa51e7557a1a3d067ea1963aabba Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Wed, 4 Oct 2023 14:38:49 -0600 Subject: [PATCH 4/7] only refresh on close, not on open editing modal --- www/js/control/ProfileSettings.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 5f4347e21..072d4267f 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -156,7 +156,10 @@ const ProfileSettings = () => { //ensure ui table updated when editor closes useEffect(() => { - refreshCollectSettings(); + if(editCollection == false) { + console.log("closed editor, time to refresh collect"); + refreshCollectSettings(); + } }, [editCollection]) async function refreshNotificationSettings() { From 69f327a8d803309df6ad9ef8b1a0996f9e90e1e9 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Mon, 9 Oct 2023 10:13:45 -0600 Subject: [PATCH 5/7] band-aid fix for collect settings setting a delay does prevent the collect settings changes from turning off tracking, but this is not a very principled fix, still looking for a better way to fix this --- www/js/control/ControlCollectionHelper.tsx | 1 - www/js/control/ProfileSettings.jsx | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/www/js/control/ControlCollectionHelper.tsx b/www/js/control/ControlCollectionHelper.tsx index fe6821f4b..d93c498a9 100644 --- a/www/js/control/ControlCollectionHelper.tsx +++ b/www/js/control/ControlCollectionHelper.tsx @@ -173,7 +173,6 @@ const ControlCollectionHelper = ({ editVis, setEditVis }) => { try{ let set = await setConfig(localConfig); setEditVis(false); - //TODO find way to not need control.update.complete event broadcast } catch(err) { Logger.displayError("Error while setting collection config", err); } diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 072d4267f..0b00efc75 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -157,8 +157,10 @@ const ProfileSettings = () => { //ensure ui table updated when editor closes useEffect(() => { if(editCollection == false) { - console.log("closed editor, time to refresh collect"); - refreshCollectSettings(); + setTimeout(function() { + console.log("closed editor, time to refresh collect"); + refreshCollectSettings(); + }, 1000); } }, [editCollection]) From 6da202ce5e13b186c24cd128a80532478a0f566b Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Sat, 21 Oct 2023 17:29:58 -0600 Subject: [PATCH 6/7] add timeout to med accuracy medium accuracy sometimes alters the tracking settings as well, this timeout resolves that --- www/js/control/ProfileSettings.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 0b00efc75..993c43814 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -261,9 +261,11 @@ const ProfileSettings = () => { refreshCollectSettings(); } - async function toggleLowAccuracy() { + async function toggleLowAccuracy() { let toggle = await helperToggleLowAccuracy(); - refreshCollectSettings(); + setTimeout(function() { + refreshCollectSettings(); + }, 1500); } const viewQRCode = function(e) { From 5386a2dc651079f4e0e1139a57531d7b4cb76341 Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Sat, 21 Oct 2023 20:50:02 -0600 Subject: [PATCH 7/7] update variable name the prior variable name was inconsistent with the rest of the file, and therefore created confusion --- www/js/control/ProfileSettings.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 993c43814..7cf22a154 100644 --- a/www/js/control/ProfileSettings.jsx +++ b/www/js/control/ProfileSettings.jsx @@ -60,7 +60,7 @@ const ProfileSettings = () => { const [showingSensed, setShowingSensed] = useState(false); const [showingLog, setShowingLog] = useState(false); const [editSync, setEditSync] = useState(false); - const [editCollection, setEditCollection] = useState(false); + const [editCollectionVis, setEditCollectionVis] = useState(false); // const [collectConfig, setCollectConfig] = useState({}); const [collectSettings, setCollectSettings] = useState({}); @@ -156,13 +156,13 @@ const ProfileSettings = () => { //ensure ui table updated when editor closes useEffect(() => { - if(editCollection == false) { + if(editCollectionVis == false) { setTimeout(function() { console.log("closed editor, time to refresh collect"); refreshCollectSettings(); }, 1000); } - }, [editCollection]) + }, [editCollectionVis]) async function refreshNotificationSettings() { console.debug('about to refreshNotificationSettings, notificationSettings = ', notificationSettings); @@ -496,7 +496,7 @@ const ProfileSettings = () => { - + );