-
Notifications
You must be signed in to change notification settings - Fork 309
Add a loading indicator for PerAccountStore #852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -295,6 +295,15 @@ class PerAccountStore extends ChangeNotifier with ChannelStore, MessageStore { | |||
final GlobalStore _globalStore; | |||
final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events | |||
|
|||
bool get isLoading => _isLoading; | |||
bool _isLoading = false; | |||
@visibleForTesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful for a widget test added later.
await store.addUser(eg.selfUser); | ||
|
||
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id, | ||
child: ProfilePage(userId: eg.selfUser.userId))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally only test this with one of the many call sites. This test does not prevent the bug where a new page is added without ZulipAppBar
, as we don't have a way to exhaustively list pages that have access to a PerAccountStoreWidget
yet.
Looks like CI is failing; could you fix that please? |
Oops, just pushed again to fix that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'm curious if you explored an approach with a toast: #465 (comment)
Would it be easy to put some code in one central place, ensuring that a toast showing the org's name is visible for each account in the loading state? (E.g., for CZO: "Connecting to Zulip Community…")
Or, a refinement (that could be annoying to implement): filter that list of toasts down to the account corresponding to the foregrounded screen, and no need to show the org's name.
In the screenshots, I'm noticing the color isn't a great match for the app bar, and the split between the app bar and the sticky recipient header is looking kind of awkward.
If we're going with this linear-indicator approach, let's definitely track that it's missing on the lightbox screen, which needs it because it's a per-account screen too.
lib/widgets/message_list.dart
Outdated
: null, // i.e., inherit | ||
), | ||
: null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this comment. A reader might see null
and think it means there's no bottom border. That would be wrong; what null
actually does is make the app bar inherit its bottom border from the AppBarTheme
.
Thanks for the review! I didn't experiment with Could you elaborate on this?
Visually, matching the background color should be fairly simple, because diff --git lib/widgets/app_bar.dart lib/widgets/app_bar.dart
index da49a639..a1c4645b 100644
--- lib/widgets/app_bar.dart
+++ lib/widgets/app_bar.dart
@@ -12,6 +12,6 @@ class ZulipAppBar extends AppBar {
bottom: PreferredSize(
preferredSize: const Size.fromHeight(4.0),
child: (isLoading)
- ? const LinearProgressIndicator(minHeight: 4.0)
+ ? LinearProgressIndicator(backgroundColor: backgroundColor, minHeight: 4.0)
: const SizedBox.shrink()));
} |
Do we have a toast library in mind to use? Or are we writing one from scratch? Looks like SnackBar is the official implementation. |
Chat thread about what type of indicator to use: |
I think it's actually fine to not have the indicator on the lightbox screen. Critically, there's very little there to get live-updated — even if you're looking at stale data there and you think it's up to date, it's hard to get misled about much as a result. In particular it never gets updated by a new message arriving. It should definitely get a comment saying we've chosen not to put the indicator there, though, and why. |
Sure, I guess that all makes sense. |
So the current revision is close to what we want, right? Is this the only thing missing:
? |
Right, will update this later. |
Updated the PR to mention the ZulipAppBar exceptions in comments after its dart doc. |
Updated the PR to handle |
Thanks! LGTM, over to Greg for his review. |
(Rebased the PR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @PIG208, and thanks @chrisbobbe for the previous reviews!
Generally this looks good. I also put a build with this PR (among others) onto my phone last week before going on vacation, and the behavior was very helpful.
A couple of small comments below. I've also pushed some additional commits on top:
c384847 wip squash? plain AppBar where isLoading always false
667adf8 app_bar [nfc]: Move ZulipAppBar.isLoading to within widget
a6965aa app_bar [nfc]: Explain why the lightbox skips ZulipAppBar
The first one reflects one comment, and can be squashed; I added it just because that change is needed for the next commit.
lib/widgets/app.dart
Outdated
appBar: ZulipAppBar( | ||
title: Text(zulipLocalizations.chooseAccountPageTitle), | ||
actions: const [ChooseAccountPageOverflowButton()]), | ||
actions: const [ChooseAccountPageOverflowButton()], | ||
isLoading: false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just AppBar
, if we're going to hard-code isLoading
here to false?
lib/widgets/inbox.dart
Outdated
appBar: AppBar(title: const Text('Inbox')), | ||
appBar: ZulipAppBar( | ||
title: const Text('Inbox'), | ||
isLoading: store.isLoading), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this pattern can be simplified. I'll push a separate commit on top to do so.
When an error occurs to a getEvents call, there isn't a visual indicator for the retry attempts. This prepares the data model for the feature. Signed-off-by: Zixuan James Li <[email protected]>
Ideally we may have test to exhaustively ensure that all pages specific to a single PerAccountStore use ZulipAppBar. Some pages with `AppBar`s are skipped, such as AboutZulip (no PerAccountStore access) and lightboxes (progress indicator is occupied for other purposes, and the AppBar can be hidden). Fixes zulip#465.
This keeps call sites simpler.
Just listing that there is an exception doesn't help much to provide guidance for someone writing a new page on whether they should also skip ZulipAppBar there. The "why" is much more helpful for that. Right at the call site is also more helpful than at the definition of ZulipAppBar, because the call site is the place someone will definitely be looking if they're contemplating whether this deviation from the pattern is appropriate, a mistake, or just an oversight.
Thanks! Rebased the PR and squashed the commit. |
Looks good! Thanks for the revision — merging. |
Preview
Fixes #465.