Skip to content
Open
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
5 changes: 2 additions & 3 deletions packages/webapp/src/containers/AddFarm/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ 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';
import { resetApiState } from '../../store/api/apiSlice';

const patchRoleUrl = (farm_id, user_id) => `${userFarmUrl}/role/farm/${farm_id}/user/${user_id}`;
const patchFarmUrl = (farm_id) => `${farmUrl}/owner_operated/${farm_id}`;
Expand Down Expand Up @@ -62,7 +61,7 @@ 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]));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If we go with the proof of concept of farm_id partition eventually. Invalidates tags line would be removed anyways.

yield put(resetApiState());

const user = getUserResult?.data;
yield put(
Expand Down
5 changes: 2 additions & 3 deletions packages/webapp/src/containers/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, resetApiState } from '../store/api/apiSlice';
import {
getSoilSampleLocationsSuccess,
onLoadingSoilSampleLocationFail,
Expand Down Expand Up @@ -658,7 +657,7 @@ export function* fetchAllSaga() {
export function* clearOldFarmStateSaga() {
yield put(resetTasks());
yield put(resetDateRange());
yield put(invalidateTags([...FarmTags, ...FarmLibraryTags]));
yield put(resetApiState());

// Reset finance loading state
yield put(setIsFetchingData(true));
Expand Down
2 changes: 2 additions & 0 deletions packages/webapp/src/store/api/apiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ import { API_TAGS, ApiTag } from './apiTags';
*/
export const invalidateTags = (tags: ApiTag[]) => api.util.invalidateTags(tags);

export const resetApiState = () => api.util.resetApiState();

const NON_JSON_ENDPOINT_KEYS = new Set(['addSupportTicket']);

export const api = createApi({
Expand Down
Loading