-
Notifications
You must be signed in to change notification settings - Fork 309
general chat #1: add support at most places #1297
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
da55117
to
b38c9bc
Compare
b38c9bc
to
4bdbc85
Compare
This comment was marked as outdated.
This comment was marked as outdated.
4bdbc85
to
02a284d
Compare
This comment was marked as resolved.
This comment was marked as resolved.
b3f2081
to
bc157cf
Compare
Screenshots: Compose box
(sending to empty topics from channel narrow is not supported on this branch; more in #1364) |
49751d6
to
d88c355
Compare
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, and sorry for the delay in my review! Small comments below.
lib/model/store.dart
Outdated
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting | ||
String get realmEmptyTopicDisplayName { | ||
assert(_realmEmptyTopicDisplayName != null); // TODO(log) | ||
return _realmEmptyTopicDisplayName ?? 'general chat'; | ||
} |
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.
test/widgets/autocomplete_test.dart
Outdated
checkTopicShown(topic3, store, expected: true); | ||
checkTopicShown('Topic one', store, expected: false); | ||
checkTopicShown('Topic two', store, expected: true); | ||
checkTopicShown('Topic three', store, expected: true); |
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.
autocomplete test [nfc]: Use plain strings for finding topic
instead of inferring it from a TopicName
Signed-off-by: Zixuan James Li <[email protected]>
Commit-message nit: I think "inferring" isn't quite the right word; if you have a TopicName
and you want its display name, you just look at its displayName
field; no inference is needed
lib/model/autocomplete.dart
Outdated
@@ -921,7 +921,7 @@ class TopicAutocompleteView extends AutocompleteView<TopicAutocompleteQuery, Top | |||
} | |||
|
|||
TopicAutocompleteResult? _testTopic(TopicAutocompleteQuery query, TopicName topic) { | |||
if (query.testTopic(topic)) { | |||
if (query.testTopic(store, topic)) { |
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.
autocomplete: Handle autocompleting to empty topic
Signed-off-by: Zixuan James Li <[email protected]>
This commit is NFC, right?
lib/model/autocomplete.dart
Outdated
// This checks for inequality because there is nothing to autocomplete to | ||
// when `raw` already matches the topic exactly. | ||
return topic.displayName != raw |
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:
// Skip this option if it matches the query exactly
(a little less verbose)
lib/widgets/inbox.dart
Outdated
@@ -537,13 +537,16 @@ class _TopicItem extends StatelessWidget { | |||
child: Text( | |||
style: TextStyle( | |||
fontSize: 17, | |||
// ignore: unnecessary_null_comparison // null topic names soon to be enabled | |||
fontStyle: topic.displayName == null ? FontStyle.italic : 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.
msglist: Display realmEmptyTopicDisplayName where empty topic appears
Signed-off-by: Zixuan James Li <[email protected]>
This is another NFC commit, right? (And it doesn't actually do what the summary line says it does, because empty topics don't appear anywhere yet?)
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.
Yeah, these commits are structured in a way so that they are not user visible without the final "do not merge" series. This way we can start merging part of these changes while still have a way to test them.
It will do what the summary says, but only after we allow empty topics in our data structures.
@@ -366,8 +366,11 @@ class MessageListAppBarTitle extends StatelessWidget { | |||
return Row( | |||
mainAxisSize: MainAxisSize.min, | |||
children: [ | |||
Flexible(child: Text(topic.displayName, style: const TextStyle( |
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.
msglist: Display realmEmptyTopicDisplayName where empty topic appears
Signed-off-by: Zixuan James Li <[email protected]>
(Same comment about this being an NFC commit.)
lib/api/route/messages.dart
Outdated
@@ -90,6 +92,7 @@ Future<GetMessagesResult> getMessages(ApiConnection connection, { | |||
bool? applyMarkdown, | |||
// bool? useFirstUnreadAnchor // omitted because deprecated | |||
}) { | |||
final supportsEmptyTopics = connection.zulipFeatureLevel! >= 334; // TODO(server-10) |
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.
clientGravatar
looks like another client-capability param, but that one is exposed to the caller of this binding. I think we should maybe also expose supportsEmptyTopics
, to make the binding as thin as possible? (Here and in other bindings)
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.
Ended up rewriting most of the last commit, and added a bunch of new tests.
bc3377d
to
cb1334d
Compare
Thanks for the review! This should be ready again. |
Thanks, looks mostly good! For these NFC commits: […] I see that you've explained them in the PR discussion:
But the commit messages themselves look confusing; they say NFC but they also read as descriptions of a user-facing change. How about adding a brief note in each commit-message body saying that the described change doesn't actually happen until we allow empty topics in our data structures, which will come in a later series of commits. Anyway, marking for Greg's review. :) |
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 to you both! Generally this looks good; comments below.
(I haven't read the "do not merge" commits.)
lib/model/autocomplete.dart
Outdated
@@ -939,10 +943,16 @@ class TopicAutocompleteView extends AutocompleteView<TopicAutocompleteQuery, Top | |||
class TopicAutocompleteQuery extends AutocompleteQuery { | |||
TopicAutocompleteQuery(super.raw); | |||
|
|||
bool testTopic(TopicName topic) { | |||
bool testTopic(PerAccountStore store, TopicName topic) { |
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.
nit: candidate result first, then the contextual data — follow pattern of other testFoo methods on other FooAutocompleteQuery classes
@@ -414,6 +417,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel | |||
/// For docs, please see [InitialSnapshot.realmWaitingPeriodThreshold]. | |||
final int realmWaitingPeriodThreshold; // TODO(#668): update this realm setting | |||
final int maxFileUploadSizeMib; // No event for this. | |||
String get realmEmptyTopicDisplayName { | |||
assert(_realmEmptyTopicDisplayName != null); // TODO(log) |
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.
This calls for a comment explaining why this condition is supposed to be unreachable — it doesn't seem obvious.
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.
Or maybe clearest: a bit of dartdoc saying not to access this unless zulipFeatureLevel is at least such-and-such. That's the idea for why this shouldn't happen, right?
String get realmEmptyTopicDisplayName { | ||
assert(_realmEmptyTopicDisplayName != null); // TODO(log) | ||
return _realmEmptyTopicDisplayName ?? 'general chat'; | ||
} | ||
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting |
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.
nit: set this group off with blank lines
test/widgets/autocomplete_test.dart
Outdated
await tester.enterText(topicInputFinder, 'general ch'); | ||
await tester.enterText(topicInputFinder, 'general cha'); | ||
await tester.pumpAndSettle(); | ||
|
||
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); |
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.
This test is already relying on the value of eg.defaultRealmEmptyTopicDisplayName
being what it is (or something like it), namely that it contains "general chat", in order for the search steps to work.
So the test should instead give explicitly the value of realmEmptyTopicDisplayName
that it's counting on. Then it can use that in this check too.
lib/model/autocomplete.dart
Outdated
// Skip this option if it matches the query exactly. | ||
return topic.displayName != raw |
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.
This comment seems to just restate what the line after it says. Cleanest to leave it out.
lib/widgets/inbox.dart
Outdated
fontSize: 17, | ||
fontStyle: topic.displayName == null ? FontStyle.italic : null, | ||
height: (20 / 17), |
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.
nit: keep fontSize and height next to each other — the "17" in height
is a reference to the "17" in fontSize
(And even if we hadn't written height
that way, those two properties are closely related and one naturally wants to read them together)
test/widgets/inbox_test.dart
Outdated
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]); | ||
|
||
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); |
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.
nit: keep checks joined into same stanza after the setup that leads to them
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]); | |
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); | |
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]); | |
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); |
lib/widgets/message_list.dart
Outdated
style: recipientHeaderTextStyle(context).copyWith( | ||
fontStyle: topic.displayName == null ? FontStyle.italic : 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.
Instead of copying the style object right after making it, let's have this recipientHeaderTextStyle
helper take a parameter. Can just be fontStyle
directly.
@@ -339,8 +339,9 @@ class MessageListAppBarTitle extends StatelessWidget { | |||
return Row( | |||
mainAxisSize: MainAxisSize.min, | |||
children: [ | |||
Flexible(child: Text(topic.displayName, style: const TextStyle( | |||
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle( |
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 have a test for this part too. Should be quick, I think; can go in the "app bar" group.
9b72b20
to
61fe655
Compare
Updated the PR. Thanks for the review! |
Signed-off-by: Zixuan James Li <[email protected]>
instead of reading TopicName.displayName Signed-off-by: Zixuan James Li <[email protected]>
Signed-off-by: Zixuan James Li <[email protected]>
While this appears to be a user facing change, it's not visible yet, not until TopicName.displayName becomes nullable. This is a part of a series of changes to handle empty topics. Signed-off-by: Zixuan James Li <[email protected]>
…ears While this appears to be a user facing change, it's not visible yet, not until TopicName.displayName becomes nullable. This is a part of a series of changes to handle empty topics. Signed-off-by: Zixuan James Li <[email protected]>
…ppears While this appears to be a user facing change, it's not visible yet, not until TopicName.displayName becomes nullable. This is a part of a series of changes to handle empty topics. Signed-off-by: Zixuan James Li <[email protected]>
Thanks! Looks good; merging. |
61fe655
to
8e21f98
Compare
Stacked on top of #1342.This addresses part of #1250.
This is the bare minimum needed for making
TopicName.displayName
nullable before we can work on the more intricate details on how parts like sending from compose box or live hint text updates work.The last three commits enable support for empty topics for testing. When merging, we leave those three commits out because we haven't yet finished working other other parts mentioned above. This allows us to review and merge related changes without interrupting beta releases with user-visible changes.
See the screenshots for what changes are included here.