From 6f5b551bdaa133ec6fa0f91f3f9621542b4217a8 Mon Sep 17 00:00:00 2001
From: Paul Frazee <pfrazee@gmail.com>
Date: Fri, 10 May 2024 21:57:21 -0700
Subject: Add shutdown message to for you feed (#3776)

---
 src/view/com/posts/Feed.tsx | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'src/view/com/posts/Feed.tsx')

diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx
index c51733d1b..e45abfedc 100644
--- a/src/view/com/posts/Feed.tsx
+++ b/src/view/com/posts/Feed.tsx
@@ -14,6 +14,7 @@ import {useLingui} from '@lingui/react'
 import {useQueryClient} from '@tanstack/react-query'
 
 import {FALLBACK_MARKER_POST} from '#/lib/api/feed/home'
+import {KNOWN_SHUTDOWN_FEEDS} from '#/lib/constants'
 import {logEvent} from '#/lib/statsig/statsig'
 import {logger} from '#/logger'
 import {isWeb} from '#/platform/detection'
@@ -36,12 +37,14 @@ import {PostFeedLoadingPlaceholder} from '../util/LoadingPlaceholder'
 import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn'
 import {DiscoverFallbackHeader} from './DiscoverFallbackHeader'
 import {FeedErrorMessage} from './FeedErrorMessage'
+import {FeedShutdownMsg} from './FeedShutdownMsg'
 import {FeedSlice} from './FeedSlice'
 
 const LOADING_ITEM = {_reactKey: '__loading__'}
 const EMPTY_FEED_ITEM = {_reactKey: '__empty__'}
 const ERROR_ITEM = {_reactKey: '__error__'}
 const LOAD_MORE_ERROR_ITEM = {_reactKey: '__load_more_error__'}
+const FEED_SHUTDOWN_MSG_ITEM = {_reactKey: '__feed_shutdown_msg_item__'}
 
 // DISABLED need to check if this is causing random feed refreshes -prf
 // const REFRESH_AFTER = STALE.HOURS.ONE
@@ -96,7 +99,7 @@ let Feed = ({
   const [isPTRing, setIsPTRing] = React.useState(false)
   const checkForNewRef = React.useRef<(() => void) | null>(null)
   const lastFetchRef = React.useRef<number>(Date.now())
-  const feedType = feed.split('|')[0]
+  const [feedType, feedUri] = feed.split('|')
 
   const opts = React.useMemo(
     () => ({enabled, ignoreFilterFor}),
@@ -196,6 +199,9 @@ let Feed = ({
 
   const feedItems = React.useMemo(() => {
     let arr: any[] = []
+    if (KNOWN_SHUTDOWN_FEEDS.includes(feedUri)) {
+      arr = arr.concat([FEED_SHUTDOWN_MSG_ITEM])
+    }
     if (isFetched) {
       if (isError && isEmpty) {
         arr = arr.concat([ERROR_ITEM])
@@ -213,7 +219,7 @@ let Feed = ({
       arr.push(LOADING_ITEM)
     }
     return arr
-  }, [isFetched, isError, isEmpty, data])
+  }, [isFetched, isError, isEmpty, data, feedUri])
 
   // events
   // =
@@ -296,6 +302,8 @@ let Feed = ({
         )
       } else if (item === LOADING_ITEM) {
         return <PostFeedLoadingPlaceholder />
+      } else if (item === FEED_SHUTDOWN_MSG_ITEM) {
+        return <FeedShutdownMsg feedUri={feedUri} />
       } else if (item.rootUri === FALLBACK_MARKER_POST.post.uri) {
         // HACK
         // tell the user we fell back to discover
@@ -307,6 +315,7 @@ let Feed = ({
     },
     [
       feed,
+      feedUri,
       error,
       onPressTryAgain,
       onPressRetryLoadMore,
-- 
cgit 1.4.1

