From c77fd588e9c6874b1e8eb4f3130b234fc3cbea63 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 28 Aug 2023 13:55:56 -0500 Subject: [PATCH 1/2] wrap mutation in runInAction (#1305) --- src/view/com/post-thread/PostThread.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index e3dd2cf1..3e951dbf 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -1,4 +1,5 @@ import React, {useRef} from 'react' +import {runInAction} from 'mobx' import {observer} from 'mobx-react-lite' import { ActivityIndicator, @@ -361,7 +362,9 @@ function* flattenThread( } } } else if (!isAscending && !post.parent && post.post.replyCount) { - post._hasMore = true + runInAction(() => { + post._hasMore = true + }) } } From e2f0770b88b24f44d066493e5e39f689feb46915 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 28 Aug 2023 17:08:21 -0700 Subject: [PATCH 2/2] Remove ability for Post component to load from URI (close #1302) (#1317) --- src/view/com/notifications/FeedItem.tsx | 5 ++--- src/view/com/post/Post.tsx | 28 ++++--------------------- src/view/com/search/SearchResults.tsx | 7 +------ 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/view/com/notifications/FeedItem.tsx b/src/view/com/notifications/FeedItem.tsx index 7b07bb30..3e0d9f5c 100644 --- a/src/view/com/notifications/FeedItem.tsx +++ b/src/view/com/notifications/FeedItem.tsx @@ -122,7 +122,7 @@ export const FeedItem = observer(function ({ } if (item.isReply || item.isMention || item.isQuote) { - if (item.additionalPost?.error) { + if (!item.additionalPost || item.additionalPost?.error) { // hide errors - it doesnt help the user to show them return } @@ -134,8 +134,7 @@ export const FeedItem = observer(function ({ noFeedback accessible={false}> }) { const pal = usePalette('default') - const store = useStores() - const [view, setView] = useState(initView) const [deleted, setDeleted] = useState(false) - useEffect(() => { - if (initView || view?.params.uri === uri) { - if (initView !== view) { - setView(initView) - } - return - } - const newView = new PostThreadModel(store, {uri, depth: 0}) - setView(newView) - newView.setup().catch(err => store.log.error('Failed to fetch post', err)) - }, [initView, setView, uri, view, view?.params.uri, store]) - // deleted // = if (deleted) { @@ -69,11 +53,7 @@ export const Post = observer(function Post({ // loading // = - if ( - !view || - (!view.hasContent && view.isLoading) || - view.params.uri !== uri - ) { + if (!view.hasContent && view.isLoading) { return ( diff --git a/src/view/com/search/SearchResults.tsx b/src/view/com/search/SearchResults.tsx index bf623d93..98427770 100644 --- a/src/view/com/search/SearchResults.tsx +++ b/src/view/com/search/SearchResults.tsx @@ -72,12 +72,7 @@ const PostResults = observer(({model}: {model: SearchUIModel}) => { return ( {model.posts.map(post => ( - + ))}