-
Notifications
You must be signed in to change notification settings - Fork 171
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
Clarify action sheet's "page context"; fix small bugs #1044
Open
gnprice
wants to merge
9
commits into
zulip:main
Choose a base branch
from
gnprice:pr-action-sheet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Most of the ways we use this field (specifically, all the ways we use it other than in findMessageListPage) aren't related to it being the message list in particular. When we add action sheets other than the message action sheet, they'll still need a page context. So prepare the way for those by giving this a name that can generalize.
And add a bit of docs clarifying the expected practice.
…sheet We closed issue zulip#24 because it was apparently resolved by an OS update. There's still a milder issue; mention that instead.
The usual Flutter idiom, which we use across the rest of the app, would call for using the parameter called `context` wherever a BuildContext is required: for getting the store or localizations, or passing to a method like showErrorDialog, and so on. That idiom doesn't work here, because that context belongs to the action sheet itself, which gets dismissed at the start of the method. Worse, it will sometimes seem to work, nondeterministically: the context only gets unmounted after the animation to dismiss the action sheet is complete, which takes something like 200ms. So the temptation to use it has been a recurring source of small bugs. Fix the problem by not passing the action sheet's context to these methods at all.
This was referenced Nov 5, 2024
…sheet opened The narrow of a given MessageListPage can change over time, in particular if viewing a topic that gets moved. If it does, the mark-unread action should follow along. Otherwise we'd have a frustrating race where mark-unread just didn't work if, for example, someone happened to resolve the topic while you were in the middle of trying to mark as unread. Fixes: zulip#1045
This is a nice small bonus from renaming the parameter that was `messageListContext` to the shorter name `pageContext`. Some of these don't quite fit in 80 columns. But the details of the parameter list are boring (because they're all the same), so it's OK that some of them go a little over.
These tests are all already relying on the detail that the setupToMessageActionSheet helper uses `eg.selfAccount` for the account. Better to encapsulate that detail, and have them rely on it giving the test cases a reference to the store directly.
Their callers always give them the shared store prepared by the setup helper setupToMessageActionSheet. Have these helpers just use that directly. If in the future we end up having a use case for customizing this behavior, it'll probably be most convenient to have them accept a connection instead of a store, anyway.
gnprice
force-pushed
the
pr-action-sheet
branch
from
November 5, 2024 02:17
adc5923
to
ef09133
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was prompted by my comment at #1041 (comment) (/cc @PIG208). But then as I got into this code I found some other small cleanups to make, and also spotted a couple of bugs to fix.
Selected commit messages
action_sheet [nfc]: Rename pageContext field on button widgets
Most of the ways we use this field (specifically, all the ways we
use it other than in findMessageListPage) aren't related to it
being the message list in particular.
When we add action sheets other than the message action sheet,
they'll still need a page context. So prepare the way for those
by giving this a name that can generalize.
action_sheet [nfc]: Avoid passing footgun context to onPressed methods
The usual Flutter idiom, which we use across the rest of the app,
would call for using the parameter called
context
wherever aBuildContext is required: for getting the store or localizations,
or passing to a method like showErrorDialog, and so on.
That idiom doesn't work here, because that context belongs to the
action sheet itself, which gets dismissed at the start of the method.
Worse, it will sometimes seem to work, nondeterministically: the
context only gets unmounted after the animation to dismiss the action
sheet is complete, which takes something like 200ms. So the
temptation to use it has been a recurring source of small bugs.
Fix the problem by not passing the action sheet's context to these
methods at all.
action_sheet: Mark as unread in current narrow, vs. from when action sheet opened
The narrow of a given MessageListPage can change over time,
in particular if viewing a topic that gets moved.
If it does, the mark-unread action should follow along. Otherwise
we'd have a frustrating race where mark-unread just didn't work
if, for example, someone happened to resolve the topic while you
were in the middle of trying to mark as unread.
Fixes: #1045