From faf3058c655fac5f49654792444f0720944268e5 Mon Sep 17 00:00:00 2001 From: Daniil <129886977+daniilminin1990@users.noreply.github.com> Date: Mon, 27 May 2024 04:03:30 +0500 Subject: [PATCH] unfortunate efforts optimistic update for card * refactor decks.service optimistic on delete decks. need to check * refactor cards.service add logic on create card optimistic. It doesnt works yet * refactor cards.service add logic on create card pessimistic and update card optimistic. It doesnt works yet. Commented code * comment code for pessimistic create and optimistic update * unfortunate efforts optimistic update for card --- src/services/cards/cards.service.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/services/cards/cards.service.ts b/src/services/cards/cards.service.ts index 000db8ee..c8a7b861 100644 --- a/src/services/cards/cards.service.ts +++ b/src/services/cards/cards.service.ts @@ -130,9 +130,19 @@ export const cardsService = flashCardsAPI.injectEndpoints({ // this is cardId invalidatesTags: ['Cards'], // async onQueryStarted({ cardId, ...args }, { dispatch, getState, queryFulfilled }) { - // const invalidateBy = cardsService.util.selectInvalidatedBy(getState(), [ - // { type: 'Cards' }, - // ]) + // //! 11111111111 + // // const patchResults: any[] = dispatch( + // // cardsService.util.updateQueryData('getCards', { id: cardId, ...args }, draft => { + // // const itemToUpdateIndex = draft.items.findIndex(card => card.id === cardId) + // // + // // if (itemToUpdateIndex === -1) { + // // return + // // } + // // Object.assign(draft.items[itemToUpdateIndex], args) + // // }) + // // ) + // //! 222222222222222 + // const invalidateBy = cardsService.util.selectInvalidatedBy(getState(), ['Cards']) // const patchResults: any[] = [] // // invalidateBy.forEach(({ originalArgs }) => {