-
Notifications
You must be signed in to change notification settings - Fork 193
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
handle unknown users everywhere #1012
base: main
Are you sure you want to change the base?
Conversation
@PIG208 could you take this one? :) |
Hi! Please take a look at the commit-discipline to fix the commit messages. Per this suggestion, I think our goal for this PR is to fix part of #716, before going over all the places that need to be updated. |
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 the second commit can be squashed into the first one.
One other thing to note is that you can use the NFC tag for your commits if they don't affect the behavior.
This is a change that we would like to have but it is not addressing #716 by finding places where we don't have unknown users. Nevertheless, this should be a good checkpoint before we start working on a PR.
lib/widgets/inbox.dart
Outdated
|
||
// TODO(i18n): List formatting, like you can do in JavaScript: | ||
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya', 'Shu']) | ||
// // 'Chris、Greg、Alya、Shu' | ||
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', '), | ||
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName).join(', '), |
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 line was already quite long:
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName).join(', '), | |
_ => narrow.otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName, | |
).join(', '), |
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 have updated the code with the suggestions you gave, and also joined the two commits to one.
Moving next to implement the issue at hand.
d5f8afe
to
cc5c85c
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.
The [nfc]
tag is usually used as a suffix. Here are some examples:
- 402f998 color [nfc]: Fix a straggling reference to Color.value, in a pigeon's doc
- 2737d4c store [nfc]: Comment in _PerAccountStoreWidgetState.didChangeDependencies
- 26069bd store [nfc]: Add indirection doLoadPerAccount
- fc80be1 store [nfc]: Offer singleton global store on binding
So we should update [nfc]: handle unknown users everywhere
to maybe i18n [nfc]: Handle unknown users everywhere
(also note the capitalization change).
lib/widgets/inbox.dart
Outdated
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', '), | ||
_ => narrow.otherRecipientIds.map((id) => | ||
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | ||
).join(', '), |
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.
Looks like the updated code is not properly indented. Could you check again?
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.
Okay, i will do that right away
lib/widgets/message_list.dart
Outdated
@@ -322,6 +322,8 @@ class MessageListAppBarTitle extends StatelessWidget { | |||
Widget build(BuildContext context) { | |||
final zulipLocalizations = ZulipLocalizations.of(context); | |||
|
|||
// TODO(i18n): provide tranlations just as 'zulipLocalizations.unknownUserName' | |||
// for 'unknown channel' |
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: tranlations
-> translations
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.
It would be better to move this comment to right before any of the lines containing (unknown channel)
, so it is easier to spot where the translation is applicable.
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.
Okay 👍 , just noticed i didn't spell that right
lib/widgets/message_list.dart
Outdated
@@ -349,7 +351,7 @@ class MessageListAppBarTitle extends StatelessWidget { | |||
if (otherRecipientIds.isEmpty) { | |||
return const Text("DMs with yourself"); | |||
} else { | |||
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)'); | |||
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName); |
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:
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName); | |
final names = otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName); |
avatar = AvatarImage(userId: otherUserId, size: _avatarSize); | ||
default: | ||
// TODO(i18n): List formatting, like you can do in JavaScript: | ||
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya']) | ||
// // 'Chris、Greg、Alya' | ||
title = narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', '); | ||
title = narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName).join(', '); |
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:
title = narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName).join(', '); | |
title = narrow.otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | |
).join(', '); |
cc5c85c
to
9a36ab5
Compare
Hi @PIG208 , I updated the changes you requested. I have some questions with regards to the issue. As I understand it, the app has a map called Amongst the solutions, it was said not to use for the first case i worked on adding the placeholders and changing some translations as well. I then saw this area with an assertion, String quoteAndReplyPlaceholder(PerAccountStore store, {
required Message message,
}) {
final sender = store.users[message.senderId];
// Is this the area i should resolve
assert(sender != null);
final url = narrowLink(store,
SendableNarrow.ofMessage(message, selfUserId: store.selfUserId),
nearMessageId: message.id);
....
} Is this an area, that requires the changes that address our issue? |
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 for the revision! Just one more comment from me.
Regarding the question on quoteAndReplyPlaceholder
, I think that one in particular is one of the places we have access to the message that contains the sender information. #716 mentioned that we should fallback to that if the user is unknown.
When we have a context like a Message that provides its own details on a user (like the message sender), we should fall back to those if the user is unknown. That way we not only don't crash, but provide helpful information, in cases like a guest user looking at older messages sent by someone no longer subscribed to their streams.
lib/widgets/inbox.dart
Outdated
_ => narrow.otherRecipientIds.map((id) => | ||
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | ||
).join(', '), |
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: use 2-space indentation
_ => narrow.otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | |
).join(', '), | |
_ => narrow.otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | |
).join(', '), |
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.
Okay, thanks for pointing that out
Let me make the changes
We should also update the commit summary, because we haven' handled unknown users everywhere yet. |
9a36ab5
to
ea6a44b
Compare
About this, I checked other areas that didn't handle the null cases and it seems to me that they have been handled to resolve unknown users. Unless i might be confuse with what is required of me. |
In this change we only start to use the translation string, but there are some other cases where we do not handle unknown users yet. |
lib/widgets/inbox.dart
Outdated
|
||
// TODO(i18n): List formatting, like you can do in JavaScript: | ||
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya', 'Shu']) | ||
// // 'Chris、Greg、Alya、Shu' | ||
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', '), | ||
_ => narrow.otherRecipientIds.map((id) => | ||
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName |
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.
bump: we use 2 spaces for indentation
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.
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 see. That should work for most cases automatically, but looks like at the line (started with store.users[id]?.fullName
) I commented, there is only one space indented from the text it aligns to (started with narrow.otherRecipientIds.map
) in the previous line.
You can count the number of spaces at the column where the n
from narrow.otherRecipientIds.map
is at, at line store.users[id]?.fullName
to see what I mean.
I would suggest the following change:
before:
_ => narrow.otherRecipientIds.map((id) =>
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName
after:
_ => narrow.otherRecipientIds.map((id) =>
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName
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 was able to add the changes as requested and i updated the PR description.
Okay, I get it now. Please can you look this code from the class AvatarImage extends StatelessWidget {
...
@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final user = store.users[userId];
/// In this case we have a condition to check if the user is null, does this mean
/// i need to add more logic to this or it handles the case as the issue describes ?
if (user == null) { // TODO(log)
return const SizedBox.shrink();
}
...
}
}
|
Thanks for the update! For the question on
We have been focusing on using the translation strings for this PR/commit, so the summary should reflect that. |
ea6a44b
to
a6a0be0
Compare
Looks good overall! This message How about something like |
Yes that true, let me make the changes |
a6a0be0
to
c3de2bb
Compare
c3de2bb
to
12a4cb6
Compare
Thanks! This looks good to me. |
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 @mofirojean for taking care of this, and @PIG208 for the previous reviews!
Generally this looks good. A few small comments below.
The PR description also needs to be fixed (just like the commit message was earlier) so it doesn't say this will fix #716.
@@ -157,7 +159,7 @@ class ReactionChip extends StatelessWidget { | |||
? userIds.map((id) { | |||
return id == store.selfUserId | |||
? 'You' | |||
: store.users[id]?.fullName ?? '(unknown user)'; // TODO(i18n) |
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: commit message doesn't quite match actual string:
i18n: Use translation for "(unknown users)"
// TODO(i18n): provide translations for 'unknown channel' | ||
final streamName = stream?.name ?? '(unknown channel)'; |
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: it's just one translation
// TODO(i18n): provide translations for 'unknown channel' | |
final streamName = stream?.name ?? '(unknown channel)'; | |
// TODO(i18n): provide translation for 'unknown channel' | |
final streamName = stream?.name ?? '(unknown channel)'; |
// TODO(i18n): provide translations just as | ||
// 'zulipLocalizations.unknownUserName' for 'unknown channel' |
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: simplify comment
// TODO(i18n): provide translations just as | |
// 'zulipLocalizations.unknownUserName' for 'unknown channel' | |
// TODO(i18n): provide translation for 'unknown channel' |
title = narrow.otherRecipientIds.map((id) => | ||
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | ||
).join(', '); |
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: indentation
title = narrow.otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | |
).join(', '); | |
title = narrow.otherRecipientIds.map((id) => | |
store.users[id]?.fullName ?? zulipLocalizations.unknownUserName | |
).join(', '); |
As described in the issue, I was able to reference the various instances of the
store.users[userId]
and most of the reference cases found had the null cases handled already, and what was left to do was to include a placeholder to adhere to Zulip's internalisation standard. Most of this could be traced to other instances that followed a similar pattern. I also performed a test to make sure nothing was broken while I implemented the changes.fixes: #716