Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got the drawers working again to reflect changes from invalidated queries #23

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function App () {
const [showDevtools] = useState(webAppConfig.ENABLE_REACT_QUERY_TOOLS !== undefined ? webAppConfig.ENABLE_REACT_QUERY_TOOLS : true);


// Inject this once for the app, for all react-query queries
// Inject this once for the app, then it is the default for all ReactQuery queries
const queryClient = new QueryClient({
defaultOptions: {
queries: {
networkMode: 'always', // Send queries to the server even if the cache has the data
// networkMode: 'always', // <-- This is not a solution, it just covers up some problem in our code, while disabling the biggest benefit of ReactQueries. Send queries to the server even if the cache has the data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing purposes, we need to have a reliable way to tell react-query to not cache anything. I don't think we have proven that we 100% understand all of the cases where react-query pulls data from its cache vs. directly from the API server. By being able to turn on a react-query configuration that forces only the freshest data from the API server, we can then isolate inconsistencies if there are any. Let's maintain the ability to test our theories about how react-query works in all edge cases before we assume that any caching or retrieval data bugs that we find are our fault. The react-query documentation describes a lot of conditions where it draws from the cache instead of pulling fresh data from the API server, and it will take time for us to experience all of those cases.

Copy link
Member Author

@SailingSteve SailingSteve Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the queries that are implemented not in this checkin, networkMode: 'always' is not needed and it would be a mistake to casually use it, maybe wrap it in conditional test logic? ReactQuery works 100% of the time for me, and I've tested it extensively. It would be great if you showed me a case where it doesn't work.

refetchOnWindowFocus: false,
refetchOnMount: true,
staleTime: 1000 * 60 * 5, // 5 minutes
Expand All @@ -53,19 +53,13 @@ function App () {
useEffect(() => {
console.log('--------- App.jsx loading ---------');
initializejQuery(() => {
console.log('--------- jQuery has been initialized ---------');
console.log('--------- jQuery has been initialized, indicates that a new session has been created ---------');
});
return () => {
// Anything in here is fired on component unmount, equiv to componentDidUnmount()
};
}, []);


const isAuth = localStorage.getItem('isAuthenticated');
if (isAuth) {
console.log('======================================== isAuthenticated: " ', isAuth, ' =============================');
}

return (
<>
<StyledEngineProvider injectFirst>
Expand All @@ -92,7 +86,7 @@ function App () {
<Route path="/" element={<Teams />} />
<Route path="*" element={<PageNotFound />} />
</Routes>
{/* Hack 1/14/25 <Footer /> */}
{/* <Footer /> has problems */}
{showDevtools && (
<ReactQueryDevtools />
)}
Expand Down
68 changes: 34 additions & 34 deletions src/js/actions/PersonActions.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import Dispatcher from '../common/dispatcher/Dispatcher';

export default {
personListRetrieve (searchText = '') {
// console.log('PersonActions, personListRetrieve searchText:', searchText);
if (searchText) {
Dispatcher.loadEndpoint('person-list-retrieve', {
searchText,
});
} else {
Dispatcher.loadEndpoint('person-list-retrieve');
}
},

personRetrieve (personId = '') {
// console.log('PersonActions, personRetrieve personId:', personId);
if (personId) {
Dispatcher.loadEndpoint('person-retrieve', {
personId,
});
} else {
Dispatcher.loadEndpoint('person-retrieve');
}
},

personSave (personId = 0, incomingData = {}) {
// console.log('PersonActions, personSave personId:', personId, ', incomingData:', incomingData);
const data = {
personId,
...incomingData,
};
Dispatcher.loadEndpoint('person-save', data);
},
};
// import Dispatcher from '../common/dispatcher/Dispatcher';
//
// export default {
// personListRetrieve (searchText = '') {
// // console.log('PersonActions, personListRetrieve searchText:', searchText);
// if (searchText) {
// Dispatcher.loadEndpoint('person-list-retrieve', {
// searchText,
// });
// } else {
// Dispatcher.loadEndpoint('person-list-retrieve');
// }
// },
//
// personRetrieve (personId = '') {
// // console.log('PersonActions, personRetrieve personId:', personId);
// if (personId) {
// Dispatcher.loadEndpoint('person-retrieve', {
// personId,
// });
// } else {
// Dispatcher.loadEndpoint('person-retrieve');
// }
// },
//
// personSave (personId = 0, incomingData = {}) {
// // console.log('PersonActions, personSave personId:', personId, ', incomingData:', incomingData);
// const data = {
// personId,
// ...incomingData,
// };
// Dispatcher.loadEndpoint('person-save', data);
// },
// };
160 changes: 80 additions & 80 deletions src/js/actions/TaskActions.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
import Dispatcher from '../common/dispatcher/Dispatcher';

export default {
taskDefinitionListRetrieve (taskGroupId, searchText = '') {
// console.log('TaskActions, taskDefinitionListRetrieve searchText:', searchText);
if (searchText) {
Dispatcher.loadEndpoint('task-definition-list-retrieve', {
taskGroupId,
searchText,
});
} else {
Dispatcher.loadEndpoint('task-definition-list-retrieve', {
taskGroupId,
});
}
},

taskDefinitionSave (taskGroupId = -1, taskDefinitionId = -1, incomingData = {}) {
// console.log('TaskActions, taskSave taskDefinitionId:', taskDefinitionId, ', incomingData:', incomingData);
const data = {
taskDefinitionId,
taskGroupId,
...incomingData,
};
Dispatcher.loadEndpoint('task-definition-save', data);
},

taskGroupListRetrieve (searchText = '') {
// console.log('TaskActions, taskGroupListRetrieve searchText:', searchText);
if (searchText) {
Dispatcher.loadEndpoint('task-group-list-retrieve', {
searchText,
});
} else {
Dispatcher.loadEndpoint('task-group-list-retrieve');
}
},

taskGroupRetrieve (taskGroupId = '') {
// console.log('TaskActions, taskGroupRetrieve taskGroupId:', taskGroupId);
if (taskGroupId) {
Dispatcher.loadEndpoint('task-group-retrieve', {
taskGroupId,
});
} else {
Dispatcher.loadEndpoint('task-group-retrieve');
}
},

taskGroupSave (taskGroupId = -1, incomingData = {}) {
// console.log('TaskActions, taskGroupSave taskGroupId:', taskGroupId, ', incomingData:', incomingData);
const data = {
taskGroupId,
...incomingData,
};
Dispatcher.loadEndpoint('task-group-save', data);
},

taskSave (personId = -1, taskDefinitionId = -1, taskGroupId = -1, incomingData = {}) {
// console.log('TaskActions, taskSave personId:', personId, ', taskDefinitionId:', taskDefinitionId, ', ', taskGroupId:', taskGroupId, ', incomingData:', incomingData);
const data = {
personId,
taskDefinitionId,
taskGroupId,
...incomingData,
};
Dispatcher.loadEndpoint('task-save', data);
},

taskStatusListRetrieve (personIdList = []) {
// console.log('TaskActions, taskStatusListRetrieve personIdList:', personIdList);
if (personIdList) {
Dispatcher.loadEndpoint('task-status-list-retrieve', {
personIdList,
});
} else {
Dispatcher.loadEndpoint('task-status-list-retrieve');
}
},
};
// import Dispatcher from '../common/dispatcher/Dispatcher';
//
// export default {
// taskDefinitionListRetrieve (taskGroupId, searchText = '') {
// // console.log('TaskActions, taskDefinitionListRetrieve searchText:', searchText);
// if (searchText) {
// Dispatcher.loadEndpoint('task-definition-list-retrieve', {
// taskGroupId,
// searchText,
// });
// } else {
// Dispatcher.loadEndpoint('task-definition-list-retrieve', {
// taskGroupId,
// });
// }
// },
//
// taskDefinitionSave (taskGroupId = -1, taskDefinitionId = -1, incomingData = {}) {
// // console.log('TaskActions, taskSave taskDefinitionId:', taskDefinitionId, ', incomingData:', incomingData);
// const data = {
// taskDefinitionId,
// taskGroupId,
// ...incomingData,
// };
// Dispatcher.loadEndpoint('task-definition-save', data);
// },
//
// taskGroupListRetrieve (searchText = '') {
// // console.log('TaskActions, taskGroupListRetrieve searchText:', searchText);
// if (searchText) {
// Dispatcher.loadEndpoint('task-group-list-retrieve', {
// searchText,
// });
// } else {
// Dispatcher.loadEndpoint('task-group-list-retrieve');
// }
// },
//
// taskGroupRetrieve (taskGroupId = '') {
// // console.log('TaskActions, taskGroupRetrieve taskGroupId:', taskGroupId);
// if (taskGroupId) {
// Dispatcher.loadEndpoint('task-group-retrieve', {
// taskGroupId,
// });
// } else {
// Dispatcher.loadEndpoint('task-group-retrieve');
// }
// },
//
// taskGroupSave (taskGroupId = -1, incomingData = {}) {
// // console.log('TaskActions, taskGroupSave taskGroupId:', taskGroupId, ', incomingData:', incomingData);
// const data = {
// taskGroupId,
// ...incomingData,
// };
// Dispatcher.loadEndpoint('task-group-save', data);
// },
//
// taskSave (personId = -1, taskDefinitionId = -1, taskGroupId = -1, incomingData = {}) {
// // console.log('TaskActions, taskSave personId:', personId, ', taskDefinitionId:', taskDefinitionId, ', ', taskGroupId:', taskGroupId, ', incomingData:', incomingData);
// const data = {
// personId,
// taskDefinitionId,
// taskGroupId,
// ...incomingData,
// };
// Dispatcher.loadEndpoint('task-save', data);
// },
//
// taskStatusListRetrieve (personIdList = []) {
// // console.log('TaskActions, taskStatusListRetrieve personIdList:', personIdList);
// if (personIdList) {
// Dispatcher.loadEndpoint('task-status-list-retrieve', {
// personIdList,
// });
// } else {
// Dispatcher.loadEndpoint('task-status-list-retrieve');
// }
// },
// };
108 changes: 54 additions & 54 deletions src/js/actions/TeamActions.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
import Dispatcher from '../common/dispatcher/Dispatcher';
import PersonStore from '../stores/PersonStore'; // eslint-disable-line import/no-cycle
import TeamStore from '../stores/TeamStore'; // eslint-disable-line import/no-cycle

export default {
addPersonToTeam (personId, teamId) {
// console.log('TeamActions, addPersonToTeam personId:', personId, ', teamId:', teamId);
const teamMemberFirstName = PersonStore.getFirstName(personId) || '';
const teamMemberLastName = PersonStore.getLastName(personId) || '';
const teamName = TeamStore.getTeamName(teamId) || '';
const data = {
personId,
teamId,
teamMemberFirstName,
teamMemberLastName,
teamName,
};
Dispatcher.loadEndpoint('add-person-to-team', data);
},

removePersonFromTeam (personId, teamId) {
// console.log('TeamActions, removePersonFromTeam personId:', personId, ', teamId:', teamId);
const data = {
personId,
teamId,
};
Dispatcher.loadEndpoint('remove-person-from-team', data);
},

teamRetrieve (teamId = '') {
// console.log('TeamActions, teamRetrieve teamId:', teamId);
if (teamId) {
Dispatcher.loadEndpoint('team-retrieve', {
teamId,
});
} else {
Dispatcher.loadEndpoint('team-retrieve');
}
},

teamListRetrieve () {
// console.log('TeamActions, teamListRetrieve');
Dispatcher.loadEndpoint('team-list-retrieve');
},

teamSave (teamId = '', incomingData = {}) {
// console.log('PersonActions, teamSave teamId:', teamId, ', incomingData:', incomingData);
const data = {
teamId,
...incomingData,
};
Dispatcher.loadEndpoint('team-save', data);
},
};
// import Dispatcher from '../common/dispatcher/Dispatcher';
// import PersonStore from '../stores/PersonStore'; // eslint-disable-line import/no-cycle
// import TeamStore from '../stores/TeamStore'; // eslint-disable-line import/no-cycle
//
// export default {
// addPersonToTeam (personId, teamId) {
// // console.log('TeamActions, addPersonToTeam personId:', personId, ', teamId:', teamId);
// const teamMemberFirstName = PersonStore.getFirstName(personId) || '';
// const teamMemberLastName = PersonStore.getLastName(personId) || '';
// const teamName = TeamStore.getTeamName(teamId) || '';
// const data = {
// personId,
// teamId,
// teamMemberFirstName,
// teamMemberLastName,
// teamName,
// };
// Dispatcher.loadEndpoint('add-person-to-team', data);
// },
//
// removePersonFromTeam (personId, teamId) {
// // console.log('TeamActions, removePersonFromTeam personId:', personId, ', teamId:', teamId);
// const data = {
// personId,
// teamId,
// };
// Dispatcher.loadEndpoint('remove-person-from-team', data);
// },
//
// teamRetrieve (teamId = '') {
// // console.log('TeamActions, teamRetrieve teamId:', teamId);
// if (teamId) {
// Dispatcher.loadEndpoint('team-retrieve', {
// teamId,
// });
// } else {
// Dispatcher.loadEndpoint('team-retrieve');
// }
// },
//
// teamListRetrieve () {
// // console.log('TeamActions, teamListRetrieve');
// Dispatcher.loadEndpoint('team-list-retrieve');
// },
//
// teamSave (teamId = '', incomingData = {}) {
// // console.log('PersonActions, teamSave teamId:', teamId, ', incomingData:', incomingData);
// const data = {
// teamId,
// ...incomingData,
// };
// Dispatcher.loadEndpoint('team-save', data);
// },
// };
2 changes: 1 addition & 1 deletion src/js/components/Drawers/AddTeamDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const AddTeamDrawer = () => {
drawerId="addTeamDrawer"
drawerOpenGlobalVariableName="addTeamDrawerOpen"
mainContentJsx={<AddTeamDrawerMainContent />}
headerTitleJsx={getAppContextValue('AddTeamDrawerLabel')}
headerTitleJsx={<>{getAppContextValue('AddTeamDrawerLabel')}</>}
headerFixedJsx={<></>}
/>
);
Expand Down
Loading
Loading