Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan-cp committed Apr 12, 2024
1 parent 1f58fcc commit 984c397
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions apps/mobile/src/components/Feed/createVirtualizedFeedEventItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import {
} from '~/generated/createVirtualizedFeedEventItemsQueryFragment.graphql';
import { removeNullValues } from '~/shared/relay/removeNullValues';

export type FeedItemTypes = 'Post' | 'FeedEvent' | 'SuggestedProfileRow';
export type FeedItemTypes = 'Post' | 'FeedEvent';
type itemType = FeedItemTypes | null;

const SUGGESTED_PROFILE_ROW_IDX = 4;

export type FeedListItemType = { key: string } & (
| {
kind: 'feed-item-navigation';
Expand Down Expand Up @@ -380,14 +382,15 @@ export function createVirtualizedFeedEventItems({
}
}

let retItems = [];
let addedRow = false;
let postCount = 0;
const itemsWithSuggestedProfileRow = [];
let inserted = false; // Tracks if the special row has been inserted

for (const item of items) {
if (!addedRow && item.kind === 'post-item-mint-link') {
postCount = postCount + 1;
if (postCount > 2) {
retItems.push({
if (!inserted && item.kind === 'post-item-mint-link') {
postCount++;
if (postCount === SUGGESTED_PROFILE_ROW_IDX) {
itemsWithSuggestedProfileRow.push({
kind: 'suggested-profile-row',
event: null,
post: null,
Expand All @@ -396,12 +399,11 @@ export function createVirtualizedFeedEventItems({
eventId: 'suggested-profile-row',
itemType: null,
});
addedRow = true;
inserted = true;
}
} else {
retItems.push(item);
}
itemsWithSuggestedProfileRow.push(item);
}

return { items: retItems };
return { items: itemsWithSuggestedProfileRow };
}

0 comments on commit 984c397

Please sign in to comment.