Fix: update posts rendered in notifs on refresh (close #1196) (#1243)

zio/stable
Paul Frazee 2023-08-22 16:36:49 -07:00 committed by GitHub
parent fcea27ea0b
commit 54706a0437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -225,12 +225,24 @@ export class NotificationsFeedItemModel {
}
setAdditionalData(additionalPost: AppBskyFeedDefs.PostView) {
if (this.additionalPost) {
this.additionalPost._replaceAll({
success: true,
headers: {},
data: {
thread: {
post: additionalPost,
},
},
})
} else {
this.additionalPost = PostThreadModel.fromPostView(
this.rootStore,
additionalPost,
)
}
}
}
export class NotificationsFeedModel {
// state

View File

@ -51,12 +51,15 @@ export const Post = observer(function Post({
useEffect(() => {
if (initView || view?.params.uri === uri) {
return // no change needed? or trigger refresh?
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, uri, view?.params.uri, store])
}, [initView, setView, uri, view, view?.params.uri, store])
// deleted
// =