Skip to content

Commit

Permalink
fixed inbox not refreshing after popping from notifications page
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiangsu committed Jul 8, 2024
1 parent 4c089eb commit 93ef270
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
28 changes: 28 additions & 0 deletions lib/inbox/bloc/inbox_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,34 @@ class InboxBloc extends Bloc<InboxEvent, InboxState> {
),
);
break;
case InboxType.all:
getRepliesResponse = await lemmy.run(
GetReplies(
auth: account!.jwt!,
unreadOnly: !event.showAll,
limit: limit,
sort: CommentSortType.new_,
page: 1,
),
);
getPersonMentionsResponse = await lemmy.run(
GetPersonMentions(
auth: account.jwt!,
unreadOnly: !event.showAll,
sort: CommentSortType.new_,
limit: limit,
page: 1,
),
);
privateMessagesResponse = await lemmy.run(
GetPrivateMessages(
auth: account.jwt!,
unreadOnly: !event.showAll,
limit: limit,
page: 1,
),
);
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/inbox/enums/inbox_type.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
enum InboxType { replies, mentions, messages }
enum InboxType { replies, mentions, messages, all }
5 changes: 3 additions & 2 deletions lib/notification/utils/navigate_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/core/auth/helpers/fetch_account.dart';
import 'package:thunder/core/singletons/lemmy_client.dart';
import 'package:thunder/inbox/bloc/inbox_bloc.dart';
import 'package:thunder/inbox/enums/inbox_type.dart';
import 'package:thunder/shared/pages/loading_page.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
import 'package:thunder/thunder/pages/notifications_pages.dart';
Expand Down Expand Up @@ -90,8 +91,6 @@ void navigateToNotificationReplyPage(BuildContext context, {required int? replyI
);

pushOnTopOfLoadingPage(context, route).then((_) {
context.read<InboxBloc>().add(const GetInboxEvent(reset: true));

// If needed, switch back to the original account or anonymous instance
if (switchedAccount) {
if (originalAccount != null) {
Expand All @@ -104,6 +103,8 @@ void navigateToNotificationReplyPage(BuildContext context, {required int? replyI
context.read<AuthBloc>().add(InstanceChanged(instance: originalAnonymousInstance));
}
}

context.read<InboxBloc>().add(const GetInboxEvent(reset: true, inboxType: InboxType.all));
});
}
}

0 comments on commit 93ef270

Please sign in to comment.