-
Notifications
You must be signed in to change notification settings - Fork 103
POC - LF- 5100 isLoading and isFetching is not farm independent #4051
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
base: integration
Are you sure you want to change the base?
Changes from 32 commits
aa9329f
8a3ba9d
acf7bfe
f9d447a
c618043
f42d9f2
b5c29c6
89554e2
b58e9f9
925eb5f
abeb944
46d522e
0ed2c17
75f9f2a
404a1c1
ba57050
8346e35
53a6a9e
720b77f
9f5485b
a42b06b
7ca95b4
b77b41a
11c7411
561453c
b3e848d
955463a
e12707e
8daa7cf
6de5764
67e7956
94982ca
1439eee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,8 +29,6 @@ import { axios, getHeader } from '../saga'; | |
| import { createAction } from '@reduxjs/toolkit'; | ||
| import i18n from '../../locales/i18n'; | ||
| import { enqueueErrorSnackbar } from '../Snackbar/snackbarSlice'; | ||
| import { invalidateTags } from '../../store/api/apiSlice'; | ||
| import { FarmLibraryTags, FarmTags } from '../../store/api/apiTags'; | ||
|
|
||
| const patchRoleUrl = (farm_id, user_id) => `${userFarmUrl}/role/farm/${farm_id}/user/${user_id}`; | ||
| const patchFarmUrl = (farm_id) => `${farmUrl}/owner_operated/${farm_id}`; | ||
|
|
@@ -61,9 +59,6 @@ export function* postFarmSaga({ payload: { showFarmNameCharacterLimitExceededErr | |
| }; | ||
| yield call(axios.patch, patchStepUrl(farm_id, user_id), step, getHeader(user_id, farm_id)); | ||
|
|
||
| // Clear old farm RTK Query data | ||
| yield put(invalidateTags([...FarmTags, ...FarmLibraryTags])); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer need to invalidate tags on switch farm. Store will clear on logout only. |
||
|
|
||
| const user = getUserResult?.data; | ||
| yield put( | ||
| postFarmSuccess({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,9 @@ const Partners = ({ | |
| }: { | ||
| setIsEditing: React.Dispatch<React.SetStateAction<boolean>>; | ||
| }) => { | ||
| const { data: esciData = [], isLoading: esciLoading } = useGetFarmAddonQuery( | ||
| `?addon_partner_id=${PARTNERS.ESCI.id}`, | ||
| ); | ||
| const { data: esciData = [], isLoading: esciLoading } = useGetFarmAddonQuery({ | ||
| params: `?addon_partner_id=${PARTNERS.ESCI.id}`, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }); | ||
|
|
||
| const hasActiveConnection = { | ||
| esci: esciData.length > 0, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,11 @@ const AddSensor = ({ isCompactSideMenu }: AddSensorProps) => { | |
| const result = await addFarmAddon(values[PARTNER]); | ||
|
|
||
| if ('error' in result) { | ||
| const isInvalidId = 'data' in result.error && result.error.data === 'Organisation not found'; | ||
| const isInvalidId = | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error is now unknown requiring stricter narrowing |
||
| result.error && | ||
| typeof result.error === 'object' && | ||
| 'data' in result.error && | ||
| result.error.data === 'Organisation not found'; | ||
| const errorMessage = isInvalidId | ||
| ? t('SENSOR.ESCI.ORGANISATION_ID_ERROR') | ||
| : t('SENSOR.ESCI.ORGANISATION_ID_GENERIC_ERROR'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,8 +151,7 @@ import { | |
| onLoadingWatercourseFail, | ||
| onLoadingWatercourseStart, | ||
| } from './watercourseSlice'; | ||
| import { api, invalidateTags } from '../store/api/apiSlice'; | ||
| import { FarmLibraryTags, FarmTags } from '../store/api/apiTags'; | ||
| import { api } from '../store/api/apiSlice'; | ||
| import { | ||
| getSoilSampleLocationsSuccess, | ||
| onLoadingSoilSampleLocationFail, | ||
|
|
@@ -603,7 +602,7 @@ export function* fetchAllSaga() { | |
| const { has_consent, user_id, farm_id } = yield select(userFarmSelector); | ||
| if (!has_consent) return history.push('/consent'); | ||
|
|
||
| yield put(api.endpoints.getSensors.initiate()); | ||
| yield put(api.endpoints.getSensors.initiate({ farm_id, payload: undefined })); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cant deny this is ugly, but the goal is to remove sagas if I recall. So using |
||
|
|
||
| const isAdmin = yield select(isAdminSelector); | ||
| const adminTasks = [ | ||
|
|
@@ -629,12 +628,12 @@ export function* fetchAllSaga() { | |
|
|
||
| // Animals | ||
| yield all([ | ||
| put(api.endpoints.getAnimals.initiate()), | ||
| put(api.endpoints.getAnimalBatches.initiate()), | ||
| put(api.endpoints.getDefaultAnimalTypes.initiate()), | ||
| put(api.endpoints.getAnimals.initiate({ farm_id, payload: undefined })), | ||
| put(api.endpoints.getAnimalBatches.initiate({ farm_id, payload: undefined })), | ||
| put(api.endpoints.getDefaultAnimalTypes.initiate({ farm_id, payload: undefined })), | ||
| put(api.endpoints.getDefaultAnimalBreeds.initiate()), | ||
| put(api.endpoints.getCustomAnimalTypes.initiate()), | ||
| put(api.endpoints.getCustomAnimalBreeds.initiate()), | ||
| put(api.endpoints.getCustomAnimalTypes.initiate({ farm_id, payload: undefined })), | ||
| put(api.endpoints.getCustomAnimalBreeds.initiate({ farm_id, payload: undefined })), | ||
| put(api.endpoints.getAnimalSexes.initiate()), | ||
| put(api.endpoints.getAnimalIdentifierTypes.initiate()), | ||
| put(api.endpoints.getAnimalIdentifierColors.initiate()), | ||
|
|
@@ -658,7 +657,6 @@ export function* fetchAllSaga() { | |
| export function* clearOldFarmStateSaga() { | ||
| yield put(resetTasks()); | ||
| yield put(resetDateRange()); | ||
| yield put(invalidateTags([...FarmTags, ...FarmLibraryTags])); | ||
|
|
||
| // Reset finance loading state | ||
| yield put(setIsFetchingData(true)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,9 @@ | |
| */ | ||
|
|
||
| const useQueries = (queries) => { | ||
| const result = queries.map((query) => query.hook(query.params)); | ||
| const result = queries.map((query) => | ||
| query.hook(query.params ? { params: query.params } : undefined), | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass params only if exists. |
||
| ); | ||
|
|
||
| const data = queries.reduce( | ||
| (dataObj, query, index) => ({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This improved typings a little bit without having to upgrade to v2.0.
Basically by reusing tome types in the previous version it could break parent types that were otherwise untouched. I never realized typescript could be so fragile.