Skip to content

Commit

Permalink
unfortunate efforts optimistic update for card
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
daniilminin1990 authored May 26, 2024
1 parent 0473ae0 commit faf3058
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/services/cards/cards.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down

0 comments on commit faf3058

Please sign in to comment.