Skip to content
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

[Device management] Hide the IP address and last activity date on current session (PSG-823) #7325

Merged
merged 2 commits into from
Oct 12, 2022

Conversation

mnaturel
Copy link
Contributor

@mnaturel mnaturel commented Oct 10, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Hiding the last seen info details on the Session Info card view when it is the current session.

Motivation and context

Closes #7324

Screenshots / GIFs

Before After

Tests

  • Enable the feature flag for new device manager
  • Go to Settings -> Security & Privacy -> Show all sessions (V2, WIP)
  • Check the current session info card view does not show the last seen details in the main screen and in the overview screen
  • Check the last seen details info is displayed for other sessions when on session overview screen

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 11

Checklist

@mnaturel mnaturel added the PR-Small PR with less than 20 updated lines label Oct 10, 2022
@mnaturel mnaturel changed the title [Device management] Hide the IP address and last activity date on current session [Device management] Hide the IP address and last activity date on current session (PSG-823) Oct 10, 2022
@mnaturel mnaturel marked this pull request as ready for review October 10, 2022 13:38
@mnaturel mnaturel requested review from a team and bmarty and removed request for a team October 10, 2022 13:38
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

A remark on the related code:

deviceInfo.lastSeenTs
                ?.takeIf { isLastSeenDetailsVisible }
                ?.let { timestamp ->
                    views.sessionInfoLastActivityTextView.isVisible = true
                    // Some code
                } ?: run {
                    views.sessionInfoLastActivityTextView.isGone = true
                }

Is not safe to me, I would prefer to have a classical if (isLastSeenDetailsVisible) block.

The reason is that if isLastSeenDetailsVisible is true the let block will be executed, but if its last statement returns null, the run block will also be executed, and this is not what we want.

This may be updated in another PR.

@mnaturel
Copy link
Contributor Author

LGTM, thanks.

A remark on the related code:

deviceInfo.lastSeenTs
                ?.takeIf { isLastSeenDetailsVisible }
                ?.let { timestamp ->
                    views.sessionInfoLastActivityTextView.isVisible = true
                    // Some code
                } ?: run {
                    views.sessionInfoLastActivityTextView.isGone = true
                }

Is not safe to me, I would prefer to have a classical if (isLastSeenDetailsVisible) block.

The reason is that if isLastSeenDetailsVisible is true the let block will be executed, but if its last statement returns null, the run block will also be executed, and this is not what we want.

This may be updated in another PR.

I am not sure to fully understand your point. Could you add more details about what could be wrong? What I targeted was to go into the run block if the deviceInfo.lastSeenTs is null or if isLastSeenDetailsVisible is false. I could update to a classical if/else to improve the readability but I guess it will not change the current behavior.

@mnaturel mnaturel added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Oct 12, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mnaturel mnaturel merged commit 7877ef9 into develop Oct 12, 2022
@mnaturel mnaturel deleted the feature/mna/device-manager-hide-ip-current-session branch October 12, 2022 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Small PR with less than 20 updated lines Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Device management] Hide the IP address and last activity date on current session
2 participants