Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions lib/shared/comment_navigator_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ class _CommentNavigatorFabState extends State<CommentNavigatorFab> {
}

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;
Expand Down Expand Up @@ -218,13 +211,6 @@ class _CommentNavigatorFabState extends State<CommentNavigatorFab> {
}

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;
Expand Down
22 changes: 20 additions & 2 deletions lib/utils/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,27 @@ Future<void> navigateToPost(
final hasFeedBloc = context.findAncestorWidgetOfExactType<BlocProvider<FeedBloc>>();
final feedBloc = hasFeedBloc != null ? context.read<FeedBloc>() : 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<PostViewMedia> 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;
Expand Down Expand Up @@ -183,7 +201,7 @@ Future<void> 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(
Expand Down