[AURORA-1970] - добавлена передача requestId
This commit is contained in:
parent
1a3fed537f
commit
2f8f4138af
@ -10,6 +10,7 @@ const initialState: CatalogueJurSliceType = {
|
|||||||
total_groups: 0,
|
total_groups: 0,
|
||||||
loading: false,
|
loading: false,
|
||||||
error: null,
|
error: null,
|
||||||
|
currentRequestId: null,
|
||||||
isGettingArchive: false,
|
isGettingArchive: false,
|
||||||
relatedGroupFilter: null,
|
relatedGroupFilter: null,
|
||||||
activeCompanyGroup: null,
|
activeCompanyGroup: null,
|
||||||
@ -32,22 +33,30 @@ const catalogueJurSlice = createSlice({
|
|||||||
resetRows(state) {
|
resetRows(state) {
|
||||||
state.raw_rows = [];
|
state.raw_rows = [];
|
||||||
state.total_groups = 0;
|
state.total_groups = 0;
|
||||||
|
// Запрос, начатый до сброса, больше не нужен: его ответ отбросится в fulfilled/rejected
|
||||||
|
state.currentRequestId = null;
|
||||||
|
state.loading = false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder
|
builder
|
||||||
.addCase(getCatalogueJurThunk.pending, (state, _) => {
|
.addCase(getCatalogueJurThunk.pending, (state, action) => {
|
||||||
|
state.currentRequestId = action.meta.requestId;
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
state.error = null;
|
state.error = null;
|
||||||
})
|
})
|
||||||
.addCase(getCatalogueJurThunk.fulfilled, (state, action) => {
|
.addCase(getCatalogueJurThunk.fulfilled, (state, action) => {
|
||||||
|
if (action.meta.requestId !== state.currentRequestId) return;
|
||||||
state.raw_rows = action.payload.items;
|
state.raw_rows = action.payload.items;
|
||||||
state.total_groups = action.payload.total;
|
state.total_groups = action.payload.total;
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
|
state.currentRequestId = null;
|
||||||
})
|
})
|
||||||
.addCase(getCatalogueJurThunk.rejected, (state, action) => {
|
.addCase(getCatalogueJurThunk.rejected, (state, action) => {
|
||||||
|
if (action.meta.requestId !== state.currentRequestId) return;
|
||||||
state.error = action.payload ?? 'Неизвестная ошибка';
|
state.error = action.payload ?? 'Неизвестная ошибка';
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
|
state.currentRequestId = null;
|
||||||
})
|
})
|
||||||
// Выбранная ГК — копия строки списка ГК: после перезагрузки списка берём свежую (счётчик ЮЛ в шапке и вкладке)
|
// Выбранная ГК — копия строки списка ГК: после перезагрузки списка берём свежую (счётчик ЮЛ в шапке и вкладке)
|
||||||
.addCase(getCompanyGroupsThunk.fulfilled, (state, action) => {
|
.addCase(getCompanyGroupsThunk.fulfilled, (state, action) => {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export interface CatalogueJurSliceType {
|
|||||||
raw_rows: ICatalogueJur[];
|
raw_rows: ICatalogueJur[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: string | null;
|
error: string | null;
|
||||||
|
currentRequestId: string | null;
|
||||||
isGettingArchive: boolean;
|
isGettingArchive: boolean;
|
||||||
relatedGroupFilter?: RelatedGroupOut | null;
|
relatedGroupFilter?: RelatedGroupOut | null;
|
||||||
activeCompanyGroup?: ICompanyGroup | null;
|
activeCompanyGroup?: ICompanyGroup | null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user