diff --git a/www/js/control/ControlCollectionHelper.tsx b/www/js/control/ControlCollectionHelper.tsx index 99318b1ac..d93c498a9 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); @@ -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"); @@ -172,7 +172,7 @@ const ControlSyncHelper = ({ editVis, setEditVis }) => { console.log("new config = ", localConfig); try{ let set = await setConfig(localConfig); - //TODO find way to not need control.update.complete event broadcast + setEditVis(false); } catch(err) { Logger.displayError("Error while setting collection config", err); } @@ -268,8 +268,7 @@ const ControlSyncHelper = ({ editVis, setEditVis }) => { {geofenceComponent} - @@ -282,4 +281,4 @@ const ControlSyncHelper = ({ editVis, setEditVis }) => { ); }; -export default ControlSyncHelper; +export default ControlCollectionHelper; diff --git a/www/js/control/ProfileSettings.jsx b/www/js/control/ProfileSettings.jsx index 8035c9462..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,8 +156,13 @@ const ProfileSettings = () => { //ensure ui table updated when editor closes useEffect(() => { - refreshCollectSettings(); - }, [editCollection]) + if(editCollectionVis == false) { + setTimeout(function() { + console.log("closed editor, time to refresh collect"); + refreshCollectSettings(); + }, 1000); + } + }, [editCollectionVis]) async function refreshNotificationSettings() { console.debug('about to refreshNotificationSettings, notificationSettings = ', notificationSettings); @@ -252,13 +257,15 @@ const ProfileSettings = () => { async function userStartStopTracking() { const transitionToForce = collectSettings.trackingOn ? 'STOP_TRACKING' : 'START_TRACKING'; - forceTransition(transitionToForce); + await forceTransition(transitionToForce); refreshCollectSettings(); } - async function toggleLowAccuracy() { + async function toggleLowAccuracy() { let toggle = await helperToggleLowAccuracy(); - refreshCollectSettings(); + setTimeout(function() { + refreshCollectSettings(); + }, 1500); } const viewQRCode = function(e) { @@ -489,7 +496,7 @@ const ProfileSettings = () => { - + );