Skip to content

Commit

Permalink
Merge pull request #1076 from Abby-Wheelis/edit-tracking-bug
Browse files Browse the repository at this point in the history
Edit tracking bug
  • Loading branch information
shankari authored Oct 23, 2023
2 parents e68b4a8 + 5386a2d commit 1b732f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
11 changes: 5 additions & 6 deletions www/js/control/ControlCollectionHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -268,8 +268,7 @@ const ControlSyncHelper = ({ editVis, setEditVis }) => {
{geofenceComponent}
</Dialog.Content>
<Dialog.Actions>
<Button onPress={() => {saveAndReload();
setEditVis(false);}}>
<Button onPress={() => {saveAndReload()}}>
Save
</Button>
<Button onPress={() => setEditVis(false)}>Cancel</Button>
Expand All @@ -282,4 +281,4 @@ const ControlSyncHelper = ({ editVis, setEditVis }) => {
);
};

export default ControlSyncHelper;
export default ControlCollectionHelper;
21 changes: 14 additions & 7 deletions www/js/control/ProfileSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -489,7 +496,7 @@ const ProfileSettings = () => {
<LogPage pageVis={showingLog} setPageVis={setShowingLog}></LogPage>

<ControlSyncHelper editVis={editSync} setEditVis={setEditSync}></ControlSyncHelper>
<ControlCollectionHelper editVis={editCollection} setEditVis={setEditCollection}></ControlCollectionHelper>
<ControlCollectionHelper editVis={editCollectionVis} setEditVis={setEditCollectionVis}></ControlCollectionHelper>

</>
);
Expand Down

0 comments on commit 1b732f7

Please sign in to comment.