-
Notifications
You must be signed in to change notification settings - Fork 310
msglist: Follow /with/ links through message moves #1029
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7ea7424
api [nfc]: Rename resolveDmElements to resolveApiNarrowForServer
chrisbobbe 48da972
msglist test [nfc]: Make groups for fetchInitial and fetchOlder tests
chrisbobbe 1b59036
msglist test [nfc]: Refactor fetchInitial smoke, preparing for more n…
chrisbobbe c655631
msglist test: Add fetchInitial smoke test that uses a topic narrow
chrisbobbe 327ae54
msglist test [nfc]: Remove indentation on an empty line
chrisbobbe a458ac2
msglist test [nfc]: Add feature-level param to setupMessageListPage
chrisbobbe be71501
msglist test: Add and use helper checkAppBarChannelTopic
chrisbobbe 5f3a682
api test [nfc]: Separate some checks on "special" narrows from other …
chrisbobbe c8494a8
msglist: Follow /with/ links through message moves
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -511,6 +511,7 @@ class MessageListView with ChangeNotifier, _MessageSequence { | |
numAfter: 0, | ||
); | ||
if (this.generation > generation) return; | ||
_adjustNarrowForTopicPermalink(result.messages.firstOrNull); | ||
store.reconcileMessages(result.messages); | ||
store.recentSenders.handleMessages(result.messages); // TODO(#824) | ||
for (final message in result.messages) { | ||
|
@@ -524,12 +525,47 @@ class MessageListView with ChangeNotifier, _MessageSequence { | |
notifyListeners(); | ||
} | ||
|
||
/// Update [narrow] for the result of a "with" narrow (topic permalink) fetch. | ||
/// | ||
/// To avoid an extra round trip, the server handles [ApiNarrowWith] | ||
/// by returning results from the indicated message's current stream/topic | ||
/// (if the user has access), | ||
/// even if that differs from the narrow's stream/topic filters | ||
/// because the message was moved. | ||
/// | ||
/// If such a "redirect" happened, this helper updates the stream and topic | ||
/// in [narrow] to match the message's current conversation. | ||
/// It also removes the "with" component from [narrow] | ||
/// whether or not a redirect happened. | ||
/// | ||
/// See API doc: | ||
/// https://zulip.com/api/construct-narrow#message-ids | ||
void _adjustNarrowForTopicPermalink(Message? someFetchedMessageOrNull) { | ||
final narrow = this.narrow; | ||
if (narrow is! TopicNarrow || narrow.with_ == null) return; | ||
|
||
switch (someFetchedMessageOrNull) { | ||
case null: | ||
// This can't be a redirect; a redirect can't produce an empty result. | ||
// (The server only redirects if the message is accessible to the user, | ||
// and if it is, it'll appear in the result, making it non-empty.) | ||
this.narrow = narrow.sansWith(); | ||
case StreamMessage(): | ||
this.narrow = TopicNarrow.ofMessage(someFetchedMessageOrNull); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Over on the widget state there's a comment which should get updated: void _modelChanged() {
if (model!.narrow != widget.narrow) {
// A message move event occurred, where propagate mode is
// [PropagateMode.changeAll] or [PropagateMode.changeLater].
widget.onNarrowChanged(model!.narrow); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh thanks for the catch. |
||
case DmMessage(): // TODO(log) | ||
assert(false); | ||
} | ||
} | ||
|
||
/// Fetch the next batch of older messages, if applicable. | ||
Future<void> fetchOlder() async { | ||
if (haveOldest) return; | ||
if (fetchingOlder) return; | ||
if (fetchOlderCoolingDown) return; | ||
assert(fetched); | ||
assert(narrow is! TopicNarrow | ||
// We only intend to send "with" in [fetchInitial]; see there. | ||
|| (narrow as TopicNarrow).with_ == null); | ||
assert(messages.isNotEmpty); | ||
_fetchingOlder = true; | ||
_updateEndMarkers(); | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
void main() { | ||
// resolveApiNarrowForServer is covered in test/api/route/messages_test.dart, | ||
// in the ApiNarrow.toJson test. | ||
} |
This file contains hidden or 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
Oops, something went wrong.
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.
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.
What if we find a
withElement
but not a stream/channel or topic, or find awithElement
and also some other operator besides those?Generally if we can't represent the exact semantics of a link with our
Narrow
type (i.e. with the message lists we're prepared to show in the UI), then this parsing function should return null so that we send the user to a browser.The one case where we might want to make a hack of accepting a link even though we'll give it only approximate semantics is where it's a link that's going to be frequently generated by Zulip, i.e. either the server or one of our clients. That's basically the story of why in main we accept
with
operators and ignore them, andnear
too.