fix: remove getDisplayNameForTypingIndicator#31495
Conversation
| } | ||
|
|
||
| const firstUserTyping = usersTyping[0]; | ||
| const firstUserTypingID = Number.isNaN(firstUserTyping) ? PersonalDetailsUtils.getAccountIDsByLogins([firstUserTyping])[0] : firstUserTyping; |
There was a problem hiding this comment.
What is the data structure of usersTyping[0]?
There was a problem hiding this comment.
@fabioh8010 usersTyping is an array of the ids of the users typing in the report, so the usersTyping[0] is a string or a number
There was a problem hiding this comment.
I'm having some difficult to understand what this line is doing 😅
For example, are you using Number.isNaN(firstUserTyping) for checking if string or number?
There was a problem hiding this comment.
yes, it was the logic from the removed method that I moved here. But I forgot to wrap the usersTyping[0] in Number as it is supposed to be a string (I will check it for sure)
| } | ||
|
|
||
| const firstUserTyping = usersTyping[0]; | ||
| const firstUserTypingID = Number.isNaN(firstUserTyping) ? PersonalDetailsUtils.getAccountIDsByLogins([firstUserTyping])[0] : firstUserTyping; |
There was a problem hiding this comment.
PersonalDetailsUtils.getAccountIDsByLogins does a traverse on the personalDetails - imo worth memoising this call, could you please try it?
|
@situchan friendly bump 🙂 |
| userTypingStatuses: {}, | ||
| }; | ||
|
|
||
| function ReportTypingIndicator(props) { |
There was a problem hiding this comment.
As we're touching this component, can we destructure props?
| const usersTyping = useMemo(() => _.filter(_.keys(props.userTypingStatuses), (loginOrAccountID) => props.userTypingStatuses[loginOrAccountID]), [props.userTypingStatuses]); | ||
| const usersTyping = useMemo(() => _.filter(_.keys(userTypingStatuses), (loginOrAccountID) => userTypingStatuses[loginOrAccountID]), [userTypingStatuses]); | ||
| const firstUserTyping = usersTyping[0]; | ||
| const firstUserTypingID = useMemo( |
There was a problem hiding this comment.
Please move old comment to here
// If the user is typing on OldDot, firstUserTyping will be a string (the user's login)
situchan
left a comment
There was a problem hiding this comment.
I think we can optimize a bit like this:
|
|
||
| // If we are offline, the user typing statuses are not up-to-date so do not show them | ||
| if (props.network.isOffline) { | ||
| if (isOffline) { |
There was a problem hiding this comment.
| if (isOffline) { | |
| if (isOffline || !firstUserTyping) { |
| const numUsersTyping = _.size(usersTyping); | ||
|
|
There was a problem hiding this comment.
| const numUsersTyping = _.size(usersTyping); |
| @@ -44,8 +49,8 @@ function ReportTypingIndicator(props) { | |||
| case 1: | |||
There was a problem hiding this comment.
replace switch/case with ? :
return usersTyping.length === 1 ? <TextWithEllipsis /> : <Text />
There was a problem hiding this comment.
as the components for this are not one-liners I'd rather do it with an if statement, it'll be more readable
|
@situchan changes applied 🙂 |
|
When type message from oldDot, it says "Someone is typing..." Screen.Recording.2023-12-01.at.7.15.05.PM.mov |
|
ok so I know what the issue is. In old logic, it fallback to this:
@koko57 we should apply same to new logic |
|
@situchan fixed! |
| leadingTextParentStyle={styles.chatItemComposeSecondaryRowOffset} | ||
| /> | ||
| ); | ||
| // If the user is typing on OldDot, firstUserTyping will be a string (the user's login) |
There was a problem hiding this comment.
| // If the user is typing on OldDot, firstUserTyping will be a string (the user's login) | |
| // If the user is typing on OldDot, firstUserTyping will be a string (the user's displayName) |
| /> | ||
| ); | ||
| // If the user is typing on OldDot, firstUserTyping will be a string (the user's login) | ||
| const firstUserTypingDisplayName = ReportUtils.getDisplayNameForParticipant(firstUserTypingID, false, false) || firstUserTyping; |
There was a problem hiding this comment.
I don't think this will work when users don't know each other.
There's case when Somone is typing... but with this change, it will never happen
There was a problem hiding this comment.
I have 2 solutions in mind:
getAccountIDsByLoginsaccepts 2nd parameter -shouldGenerateAccountID. If it's obvious that 1st param is notloginbutdisplayName, no need to generate random accountID but just return 0 or null. And then update this line like this:
const firstUserTypingDisplayName = firstUserTypingID ? ReportUtils.getDisplayNameForParticipant(firstUserTypingID, false, false) : firstUserTyping;
- check displayName if it comes from oldDot by doing email/phone validation
I prefer 1st one since user can still set any random email as display name
There was a problem hiding this comment.
@situchan can even such a scenario occur? How could I reproduce it?
There was a problem hiding this comment.
which one are you not able to reproduce?
There was a problem hiding this comment.
Here's repro step:
- on A, create new chat with B
- A sends any message to B
- on B, type something
- Observe chat on A
There was a problem hiding this comment.
Please don't set display name on both accounts and try again
There was a problem hiding this comment.
I think the purpose of hidden logic is to secure sensitive info (login in our case)
So if display name not set, show "Hidden"
if display name set, show that display name
There was a problem hiding this comment.
but for one of them it was set automatically
There was a problem hiding this comment.
Maybe you logged with google?
Btw you can unset display name in setting
There was a problem hiding this comment.
I unset it, still the same. I'll get back to it on Monday
Screen.Recording.2023-12-01.at.18.40.35.mp4
| const firstUserTypingID = useMemo( | ||
| () => (firstUserTyping && isUserTypingADisplayName ? PersonalDetailsUtils.getAccountIDsByLogins([firstUserTyping])[0] : firstUserTyping), | ||
| [firstUserTyping, isUserTypingADisplayName], | ||
| ); |
There was a problem hiding this comment.
As per below line, this code block will never run.
const firstUserTypingDisplayName = isUserTypingADisplayName ? firstUserTyping : ReportUtils.getDisplayNameForParticipant(firstUserTypingID, false, false);
This will cause regression of displaying email instead of displayName whenfirstUserTyping is login
There was a problem hiding this comment.
do we have such a case? Can you reproduce it for me? For all the users I have in the OldDot firstUserTyping is an id of digits.
There was a problem hiding this comment.
I am not sure about that case too. But I am just concerned about deprecating this old code which tries to find user info with login
App/src/libs/actions/PersonalDetails.ts
Lines 71 to 79 in 617c2dd
There was a problem hiding this comment.
This old code should have been simplified like this if there's not such case of login
if (Number.isNaN(accountID)) {
return userAccountIDOrLogin;
}
Does my concern make sense?
There was a problem hiding this comment.
but from the old code we would still return userAccountIDOrLogin (whatever is saved as firstUserTyping) to be shown and here we also show it
There was a problem hiding this comment.
What I'd like to confirm is that the old code was redundant and could be simplified like this:
if (Number.isNaN(accountID)) {
return userAccountIDOrLogin;
}
| /> | ||
| ); | ||
| // If the user is typing on OldDot, firstUserTyping will be a string (the user's displayName) | ||
| const firstUserTypingDisplayName = isUserTypingADisplayName ? firstUserTyping : ReportUtils.getDisplayNameForParticipant(firstUserTypingID, false, false); |
There was a problem hiding this comment.
If there's no case of login as firstUserTyping, this code can be updated like this:
| const firstUserTypingDisplayName = isUserTypingADisplayName ? firstUserTyping : ReportUtils.getDisplayNameForParticipant(firstUserTypingID, false, false); | |
| const firstUserTypingDisplayName = isUserTypingADisplayName ? firstUserTyping : ReportUtils.getDisplayNameForParticipant(firstUserTyping, false, false); |
And remove unnecessary firstUserTypingID
There was a problem hiding this comment.
So is there a posibility that firstUserTyping is a login or not? In which case then? Maybe I'm missing something
There was a problem hiding this comment.
Do you agree with my code suggestion above?
|
@puneetlath can you please confirm in backend App/src/libs/actions/PersonalDetails.ts Lines 71 to 79 in 617c2dd This old code which gets personal details by login doesn't make sense to me. Not able to find this case. userAccountIDOrLogin could be simply returned
|
|
Oh interesting. It looks like the back-end does still use login for reportUserIsTyping. We should update it to use accountID. |
Upon testing, I think it's not |
|
@puneetlath @situchan what's the final decision about this login/display name logic? |
|
@puneetlath @situchan friendly bump 🙂 I think that this logic @situchan question here doesn't cause this regression. |
|
Anything pending from me? |
|
My apologies for the delay. Yes, it looks like only login is not sent in |
|
@situchan so as we're not getting login I'm not insisting on the logic I've added. I applied the changes removing this check. Asking for re-review 🙂 |
|
please fix lint |
|
@situchan fixed! |
Reviewer Checklist
Screenshots/VideosAndroid: Nativedesktop-android-hidden-user.movAndroid: mWeb ChromeiOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safarinewdot.movolddot.movMacOS: Desktopdesktop-android-hidden-user.mov |
puneetlath
left a comment
There was a problem hiding this comment.
Great job with this. Sorry for the delays on my side.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.4.21-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.21-4 🚀
|
1 similar comment
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.21-4 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.21-4 🚀
|
First PR for #31312
Details
Fixed Issues
$ #31312
PROPOSAL: $ #31312 (comment)
Tests
[Typing User Name] is typing...Offline tests
N/A
QA Steps
[Typing User Name] is typing...PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop