Skip to content

Commit 5723336

Browse files
committed
account switch avatar fix, tip success message on toast
1 parent 1abd28b commit 5723336

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

lib/features/threads/presentation/thread_feed/view/thread_feed_view.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ class _ThreadFeedViewState extends State<ThreadFeedView>
6464
centerTitle: true,
6565
leading: Builder(
6666
builder: (context) {
67-
if (isLoggedIn) {
68-
final userName = context.read<UserController>().userData?.accountName;
67+
final userName = context.select<UserController, String?>(
68+
(controller) => controller.userData?.accountName);
69+
if (isLoggedIn && userName != null) {
6970
return Padding(
7071
padding: const EdgeInsets.only(left: 8),
7172
child: UserProfileImage(

lib/features/threads/presentation/thread_feed/widgets/upvote/upvote_dialog.dart

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ class _UpvoteDialogState extends State<UpvoteDialog> {
174174
return;
175175
}
176176
if (_tipFeedbackMessage != null) {
177-
setState(() {
178-
_tipFeedbackMessage = null;
179-
_tipFeedbackSuccess = false;
180-
});
177+
_clearTipFeedback();
181178
}
182179
final initialTipToken =
183180
_readStoredTipToken(userData.accountName);
@@ -496,16 +493,28 @@ class _UpvoteDialogState extends State<UpvoteDialog> {
496493

497494
void _showTipFeedback(String message, {required bool success}) {
498495
if (!mounted) return;
499-
setState(() {
500-
_tipFeedbackMessage = message;
501-
_tipFeedbackSuccess = success;
502-
});
496+
if (success) {
497+
if (_tipFeedbackMessage != null) {
498+
_clearTipFeedback();
499+
}
500+
} else {
501+
setState(() {
502+
_tipFeedbackMessage = message;
503+
_tipFeedbackSuccess = success;
504+
});
505+
}
503506
widget.rootContext.showSnackBar(message);
504507
}
505508

506509
void _clearTipFeedback() {
507-
_tipFeedbackMessage = null;
508-
_tipFeedbackSuccess = false;
510+
if (!mounted) return;
511+
if (_tipFeedbackMessage == null && !_tipFeedbackSuccess) {
512+
return;
513+
}
514+
setState(() {
515+
_tipFeedbackMessage = null;
516+
_tipFeedbackSuccess = false;
517+
});
509518
}
510519

511520
Future<void> _initTransferCallbacks() async {

0 commit comments

Comments
 (0)