diff --git a/app/components/post_list/post_list.tsx b/app/components/post_list/post_list.tsx
index 4c8f22ff4..b55cd7f59 100644
--- a/app/components/post_list/post_list.tsx
+++ b/app/components/post_list/post_list.tsx
@@ -65,7 +65,7 @@ type ScrollIndexFailed = {
};
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
-const keyExtractor = (item: PostListItem | PostListOtherItem) => (item.type === 'post' ? item.value.id : item.value);
+const keyExtractor = (item: PostListItem | PostListOtherItem) => (item.type === 'post' ? item.value.currentPost.id : item.value);
const styles = StyleSheet.create({
flex: {
@@ -272,7 +272,8 @@ const PostList = ({
return ();
}
default: {
- const post = item.value;
+ const post = item.value.currentPost;
+ const {isSaved, nextPost, previousPost} = item.value;
const skipSaveddHeader = (location === Screens.THREAD && post.id === rootId);
const postProps = {
appsEnabled,
@@ -281,12 +282,12 @@ const PostList = ({
isPostAcknowledgementEnabled,
highlight: highlightedId === post.id,
highlightPinnedOrSaved,
- isSaved: post.isSaved,
+ isSaved,
key: post.id,
location,
- nextPost: post.nextPost,
+ nextPost,
post,
- previousPost: post.previousPost,
+ previousPost,
rootId,
shouldRenderReplyButton,
skipSaveddHeader,
@@ -313,7 +314,7 @@ const PostList = ({
if (highlightedId && orderedPosts && !scrolledToHighlighted.current) {
scrolledToHighlighted.current = true;
// eslint-disable-next-line max-nested-callbacks
- const index = orderedPosts.findIndex((p) => p.type === 'post' && p.value.id === highlightedId);
+ const index = orderedPosts.findIndex((p) => p.type === 'post' && p.value.currentPost.id === highlightedId);
if (index >= 0 && listRef.current) {
listRef.current?.scrollToIndex({
animated: true,
diff --git a/app/screens/home/recent_mentions/recent_mentions.tsx b/app/screens/home/recent_mentions/recent_mentions.tsx
index a72c71ebf..42dcf2170 100644
--- a/app/screens/home/recent_mentions/recent_mentions.tsx
+++ b/app/screens/home/recent_mentions/recent_mentions.tsx
@@ -151,9 +151,9 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT
);
diff --git a/app/screens/home/saved_messages/saved_messages.tsx b/app/screens/home/saved_messages/saved_messages.tsx
index 2949104ce..12628123b 100644
--- a/app/screens/home/saved_messages/saved_messages.tsx
+++ b/app/screens/home/saved_messages/saved_messages.tsx
@@ -152,9 +152,9 @@ function SavedMessages({appsEnabled, posts, currentTimezone, customEmojiNames, i
diff --git a/app/screens/home/search/results/post_results.tsx b/app/screens/home/search/results/post_results.tsx
index 226e6ebba..f0178cdb3 100644
--- a/app/screens/home/search/results/post_results.tsx
+++ b/app/screens/home/search/results/post_results.tsx
@@ -51,9 +51,9 @@ const PostResults = ({
);
diff --git a/app/screens/pinned_messages/pinned_messages.tsx b/app/screens/pinned_messages/pinned_messages.tsx
index fb9d40295..c8e4a4c1b 100644
--- a/app/screens/pinned_messages/pinned_messages.tsx
+++ b/app/screens/pinned_messages/pinned_messages.tsx
@@ -132,9 +132,9 @@ function SavedMessages({
highlightPinnedOrSaved={false}
isCRTEnabled={isCRTEnabled}
location={Screens.PINNED_MESSAGES}
- key={item.value.id}
+ key={item.value.currentPost.id}
nextPost={undefined}
- post={item.value}
+ post={item.value.currentPost}
previousPost={undefined}
showAddReaction={false}
shouldRenderReplyButton={false}
diff --git a/app/utils/post_list/index.ts b/app/utils/post_list/index.ts
index 86e2f8ab7..4f9ae2aa8 100644
--- a/app/utils/post_list/index.ts
+++ b/app/utils/post_list/index.ts
@@ -66,17 +66,17 @@ function combineUserActivityPosts(orderedPosts: PostList) {
combinedCount = 0;
continue;
- } else if (item.type === 'post' && item.value.deleteAt) {
+ } else if (item.type === 'post' && item.value.currentPost.deleteAt) {
out.push(item);
lastPostIsUserActivity = false;
combinedCount = 0;
} else {
- const postIsUserActivity = item.type === 'post' && Post.USER_ACTIVITY_POST_TYPES.includes(item.value.type);
+ const postIsUserActivity = item.type === 'post' && Post.USER_ACTIVITY_POST_TYPES.includes(item.value.currentPost.type);
if (postIsUserActivity && lastPostIsUserActivity && combinedCount < MAX_COMBINED_SYSTEM_POSTS) {
- out[out.length - 1].value += '_' + item.value.id;
+ out[out.length - 1].value += '_' + item.value.currentPost.id;
} else if (postIsUserActivity) {
- out.push({type: 'user-activity', value: `${COMBINED_USER_ACTIVITY}${item.value.id}`});
+ out.push({type: 'user-activity', value: `${COMBINED_USER_ACTIVITY}${item.value.currentPost.id}`});
combinedCount = 1;
changed = true;
} else {
@@ -193,8 +193,8 @@ export function selectOrderedPosts(
// Iterating through the posts from oldest to newest
for (let i = posts.length - 1; i >= 0; i--) {
- const post: PostWithPrevAndNext = posts[i];
- post.isSaved = savedPostIds.has(post.id);
+ const post: PostWithPrevAndNext = {currentPost: posts[i]};
+ post.isSaved = savedPostIds.has(post.currentPost.id);
if (includePrevNext) {
post.nextPost = posts[i - 1];
if (!isThreadScreen || out[out.length - 1]?.type !== 'thread-overview') {
@@ -204,25 +204,25 @@ export function selectOrderedPosts(
if (
!post ||
- (post.type === Post.POST_TYPES.EPHEMERAL_ADD_TO_CHANNEL && !isThreadScreen)
+ (post.currentPost.type === Post.POST_TYPES.EPHEMERAL_ADD_TO_CHANNEL && !isThreadScreen)
) {
continue;
}
// Filter out join/leave messages if necessary
- if (shouldFilterJoinLeavePost(post, showJoinLeave, currentUsername)) {
+ if (shouldFilterJoinLeavePost(post.currentPost, showJoinLeave, currentUsername)) {
continue;
}
// Push on a date header if the last post was on a different day than the current one
- const postDate = new Date(post.createAt);
+ const postDate = new Date(post.currentPost.createAt);
if (timezoneEnabled) {
const currentOffset = toMilliseconds({minutes: postDate.getTimezoneOffset()});
if (currentTimezone) {
const zone = moment.tz.zone(currentTimezone);
if (zone) {
- const timezoneOffset = toMilliseconds({minutes: zone.utcOffset(post.createAt)});
- postDate.setTime(post.createAt + (currentOffset - timezoneOffset));
+ const timezoneOffset = toMilliseconds({minutes: zone.utcOffset(post.currentPost.createAt)});
+ postDate.setTime(post.currentPost.createAt + (currentOffset - timezoneOffset));
}
}
}
@@ -235,8 +235,8 @@ export function selectOrderedPosts(
if (
lastViewedAt &&
- post.createAt > lastViewedAt &&
- (post.userId !== currentUserId || isFromWebhook(post)) &&
+ post.currentPost.createAt > lastViewedAt &&
+ (post.currentPost.userId !== currentUserId || isFromWebhook(post.currentPost)) &&
!addedNewMessagesIndicator &&
indicateNewMessages
) {
diff --git a/types/components/post_list.ts b/types/components/post_list.ts
index 0415faf7d..88a4dbfa4 100644
--- a/types/components/post_list.ts
+++ b/types/components/post_list.ts
@@ -14,7 +14,7 @@ export type ViewableItemsChangedListenerEvent = (viewableItms: ViewToken[]) => v
export type ScrollEndIndexListener = (fn: (endIndex: number) => void) => () => void;
export type ViewableItemsListener = (fn: (viewableItems: ViewToken[]) => void) => () => void;
-export type PostWithPrevAndNext = PostModel & {nextPost?: PostModel; previousPost?: PostModel; isSaved?: boolean};
+export type PostWithPrevAndNext = {currentPost: PostModel; nextPost?: PostModel; previousPost?: PostModel; isSaved?: boolean};
export type PostListItem = {
type: 'post';