Skip to content

Commit

Permalink
add filtering of middle fetched inbox items
Browse files Browse the repository at this point in the history
andreymikhadyuk committed Dec 4, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@@ -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;
@@ -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,

0 comments on commit 37d5093

Please sign in to comment.