From dec13f8c9c2413e86ddecb84d3433891b6ea37b4 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 14 Aug 2023 17:41:22 -0400 Subject: [PATCH] MM-49063 Silence warning when lastViewedAt is undefined (#24252) * MM-49063 Silence warning when lastViewedAt is undefined * Fix type error --- .../channels/src/components/post_view/post_list/index.tsx | 7 +++++-- webapp/channels/src/components/post_view/post_view.tsx | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/webapp/channels/src/components/post_view/post_list/index.tsx b/webapp/channels/src/components/post_view/post_list/index.tsx index 3d532d1eef..72d44e02ad 100644 --- a/webapp/channels/src/components/post_view/post_list/index.tsx +++ b/webapp/channels/src/components/post_view/post_list/index.tsx @@ -36,7 +36,7 @@ const memoizedGetLatestPostId = memoizeResult((postIds: string[]) => getLatestPo interface Props { focusedPostId?: string; - unreadChunkTimeStamp: number; + unreadChunkTimeStamp?: number; changeUnreadChunkTimeStamp: (lastViewedAt: number) => void; channelId: string; } @@ -75,7 +75,10 @@ function makeMapStateToProps() { atOldestPost = Boolean(chunk.oldest); } - const shouldHideNewMessageIndicator = shouldStartFromBottomWhenUnread && !isPostsChunkIncludingUnreadsPosts(state, chunk!, unreadChunkTimeStamp); + let shouldHideNewMessageIndicator = false; + if (unreadChunkTimeStamp != null) { + shouldHideNewMessageIndicator = shouldStartFromBottomWhenUnread && !isPostsChunkIncludingUnreadsPosts(state, chunk!, unreadChunkTimeStamp); + } if (postIds) { formattedPostIds = preparePostIdsForPostList(state, {postIds, lastViewedAt, indicateNewMessages: !shouldHideNewMessageIndicator}); diff --git a/webapp/channels/src/components/post_view/post_view.tsx b/webapp/channels/src/components/post_view/post_view.tsx index 6bf78f3baa..a3fab27647 100644 --- a/webapp/channels/src/components/post_view/post_view.tsx +++ b/webapp/channels/src/components/post_view/post_view.tsx @@ -10,7 +10,7 @@ import {Preferences} from 'utils/constants'; import PostList from './post_list'; interface Props { - lastViewedAt: number; + lastViewedAt?: number; channelLoading: boolean; channelId: string; focusedPostId?: string; @@ -18,7 +18,7 @@ interface Props { } interface State { - unreadChunkTimeStamp: number; + unreadChunkTimeStamp?: number; loaderForChangeOfPostsChunk: boolean; channelLoading: boolean; shouldStartFromBottomWhenUnread: boolean;