Skip to content

Commit

Permalink
add filtering of middle fetched inbox items
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Dec 4, 2023
1 parent 3a90d46 commit 37d5093
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/shared/hooks/useCases/useInboxItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ export const useInboxItems = (
useEffect(() => {
(async () => {
try {
const { firstDocTimestamp: startAt, lastDocTimestamp: endAt } =
inboxItems;
const {
data,
firstDocTimestamp: startAt,
lastDocTimestamp: endAt,
} = inboxItems;

if (!userId || !startAt || !endAt) {
return;
Expand All @@ -243,8 +246,14 @@ export const useInboxItems = (
return;
}

const filteredInboxItems = data
? fetchedInboxItems.filter((fetchedItem) =>
data.every((item) => item.itemId !== fetchedItem.itemId),
)
: fetchedInboxItems;

addNewInboxItems(
fetchedInboxItems.map((item) => ({
filteredInboxItems.map((item) => ({
item,
statuses: {
isAdded: false,
Expand Down

0 comments on commit 37d5093

Please sign in to comment.