diff --git a/lib/shared/comment_navigator_fab.dart b/lib/shared/comment_navigator_fab.dart index 6d3e183e4..87ccbfd29 100644 --- a/lib/shared/comment_navigator_fab.dart +++ b/lib/shared/comment_navigator_fab.dart @@ -154,13 +154,6 @@ class _CommentNavigatorFabState extends State { } void navigateToParent() { - if (widget.comments == null) { - // This is a placeholder to allow the previous post page to function correctly. - // TODO: Remove this logic when we deprecate the legacy post page - navigateUp(); - return; - } - var unobstructedVisibleRange = widget.listController.unobstructedVisibleRange; int previousIndex = (unobstructedVisibleRange?.$1 ?? 0) - 1; @@ -218,13 +211,6 @@ class _CommentNavigatorFabState extends State { } void navigateToNextParent() { - if (widget.comments == null) { - // This is a placeholder to allow the previous post page to function correctly. - // TODO: Remove this logic when we deprecate the legacy post page - navigateDown(); - return; - } - var unobstructedVisibleRange = widget.listController.unobstructedVisibleRange; int nextIndex = (unobstructedVisibleRange?.$1 ?? 0) + 1; diff --git a/lib/utils/navigation.dart b/lib/utils/navigation.dart index 657caaef7..2e8ad9854 100644 --- a/lib/utils/navigation.dart +++ b/lib/utils/navigation.dart @@ -151,9 +151,27 @@ Future navigateToPost( final hasFeedBloc = context.findAncestorWidgetOfExactType>(); final feedBloc = hasFeedBloc != null ? context.read() : null; + PostViewMedia? pvm = postViewMedia; + + if (pvm == null) { + final client = LemmyClient.instance.lemmyApiV3; + final account = await fetchActiveProfileAccount(); + + GetPostResponse getPostResponse = await client.run( + GetPost( + auth: account?.jwt, + id: postId, + ), + ); + + List postViewMedias = await parsePostViews([getPostResponse.postView]); + + pvm = postViewMedias.first; + } + // Mark post as read when tapped if (authBloc.state.isLoggedIn) { - feedBloc?.add(FeedItemActionedEvent(postId: postViewMedia?.postView.post.id ?? postId, postAction: PostAction.read, value: true)); + feedBloc?.add(FeedItemActionedEvent(postId: pvm.postView.post.id, postAction: PostAction.read, value: true)); } final state = thunderBloc.state; @@ -183,7 +201,7 @@ Future navigateToPost( BlocProvider(create: (context) => AnonymousSubscriptionsBloc()), ], child: PostPage( - initialPostViewMedia: postViewMedia!, + initialPostViewMedia: pvm!, onPostUpdated: (PostViewMedia postViewMedia) { // Manually marking the read attribute as true when navigating to post since there is a case where the API call to mark the post as read from the feed page is not completed in time feedBloc?.add(FeedItemUpdatedEvent(