Skip to content

Commit

Permalink
add batch number to inbox items
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Oct 30, 2023
1 parent 8808629 commit df853d6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/pages/inbox/BaseInbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const InboxPage: FC<InboxPageProps> = (props) => {
loading: areInboxItemsLoading,
hasMore: hasMoreInboxItems,
fetch: fetchInboxItems,
batchNumber,
} = useInboxItems(feedItemIdsForNotListening, {
unread: queryParams.unread === "true",
});
Expand Down Expand Up @@ -257,6 +258,7 @@ const InboxPage: FC<InboxPageProps> = (props) => {
feedItems={inboxItems}
loading={areInboxItemsLoading || !user}
shouldHideContent={!user}
batchNumber={batchNumber}
onFetchNext={fetchMoreInboxItems}
renderFeedItemBaseContent={renderFeedItemBaseContent}
renderChatChannelItem={renderChatChannelItem}
Expand Down
3 changes: 2 additions & 1 deletion src/shared/hooks/useCases/useInboxItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { FeedLayoutItemWithFollowData } from "@/shared/interfaces";
import { FeedItemFollow, FeedItemFollowWithMetadata } from "@/shared/models";
import { inboxActions, InboxItems, selectInboxItems } from "@/store/states";

interface Return extends Pick<InboxItems, "data" | "loading" | "hasMore"> {
interface Return
extends Pick<InboxItems, "data" | "loading" | "hasMore" | "batchNumber"> {
fetch: () => void;
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/states/inbox/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getInboxItems = createAsyncAction(
limit?: number;
unread?: boolean;
},
Omit<InboxItems, "loading">,
Omit<InboxItems, "loading" | "batchNumber">,
Error,
string
>();
Expand Down
2 changes: 2 additions & 0 deletions src/store/states/inbox/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const initialInboxItems: InboxItems = {
hasMore: false,
firstDocTimestamp: null,
lastDocTimestamp: null,
batchNumber: 0,
};

const initialState: InboxState = {
Expand Down Expand Up @@ -432,6 +433,7 @@ export const reducer = createReducer<InboxState, Action>(initialState)
...payload,
data: payloadData && (nextState.items.data || []).concat(payloadData),
loading: false,
batchNumber: nextState.items.batchNumber + 1,
};
}),
)
Expand Down
1 change: 1 addition & 0 deletions src/store/states/inbox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface InboxItems {
hasMore: boolean;
firstDocTimestamp: Timestamp | null;
lastDocTimestamp: Timestamp | null;
batchNumber: number;
}

export interface InboxState {
Expand Down

0 comments on commit df853d6

Please sign in to comment.