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

Fix the unread count not going away when you've signed out #13600

Merged
merged 15 commits into from
Dec 30, 2022

Conversation

tgolen
Copy link
Contributor

@tgolen tgolen commented Dec 14, 2022

Fixed Issues

$ #11671

Tests

For web, desktop, and mobile web:

  1. Sign in and have another account send you a message
  2. Verify that the unread counter goes up (either page title or icon badge). For mobile web, you need to open the browser window which shows the open tabs in order to verify the page titles.
  3. Access the unread chat
  4. Verify that the unread counter goes down
  5. Make sure you have at least 1 unread chat showing on the counter and sign out
  6. Verify that the unread counter goes away completely

For native devices:
The badge counters don't work in local environment, so they can't really be tested. Just generally do some regression testing to ensure that the unread stuff works like it should

  1. Sign in and have another account send you a message
  2. Verify that the LHN appears with the unread chat
  3. Go into the chat
  4. Go back to the LHN and verify the chat is no longer marked as unread
  • Verify that no errors appear in the JS console

Offline tests

  1. Be signed into the app with an unread chat
  2. Sign out
  3. Verify that the counter goes away
web offline test video
2022-12-14_13-42-55.mp4

QA Steps

  1. Sign in and have another account send you a message
  2. Verify that the unread counter goes up (either page title or icon badge). For mobile web, you need to open the browser window which shows the open tabs in order to verify the page titles.
  3. Access the unread chat
  4. Verify that the unread counter goes down
  5. Make sure you have at least 1 unread chat showing on the counter and sign out
  6. Verify that the unread counter goes away completely

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
2022-12-14_13-19-25.mp4
Mobile Web - Chrome
2022-12-14_13-46-21.mp4
Mobile Web - Safari
2022-12-14_13-47-05.mp4
Desktop
2022-12-14_13-20-32.mp4
iOS
2022-12-14_13-26-38.mp4
Android
2022-12-14_13-32-16.mp4

@tgolen tgolen self-assigned this Dec 14, 2022
@tgolen tgolen marked this pull request as ready for review December 14, 2022 20:55
@tgolen tgolen requested a review from a team as a code owner December 14, 2022 20:55
@melvin-bot melvin-bot bot requested review from puneetlath and sobitneupane and removed request for a team December 14, 2022 20:55
@melvin-bot
Copy link

melvin-bot bot commented Dec 14, 2022

@puneetlath @sobitneupane One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@puneetlath
Copy link
Contributor

@tgolen lint check is failing.

@puneetlath
Copy link
Contributor

@sobitneupane if you're able to get to this soon, then I'll let you take the first crack at it.

@tgolen
Copy link
Contributor Author

tgolen commented Dec 14, 2022

Fixed the lint errors 👍

@sobitneupane
Copy link
Contributor

@tgolen I didn't get the expected output. I tried sending some messages. But unread indicator did not update.

Screen.Recording.2022-12-15.at.11.44.12.mov

@fedirjh
Copy link
Contributor

fedirjh commented Dec 15, 2022

@tgolen I didn't get the expected output. I tried sending some messages. But unread indicator did not update.

@sobitneupane i think that the subscription isn't imported anywhere in the App

@@ -10,7 +10,6 @@ import compose from '../../compose';
import * as PersonalDetails from '../../actions/PersonalDetails';
import * as Pusher from '../../Pusher/pusher';
import PusherConnectionManager from '../../PusherConnectionManager';
import UnreadIndicatorUpdater from '../../UnreadIndicatorUpdater';
import ROUTES from '../../../ROUTES';

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, sorry. I think I might have broken this when I just fixed the linter tests via the GitHub web interface. Sorry about that! Let me do this properly and test it out again.

Copy link
Contributor

Choose a reason for hiding this comment

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

changes looks good

@tgolen
Copy link
Contributor Author

tgolen commented Dec 15, 2022

OK, I fixed the lib import and retested it to make sure it's working again.

fedirjh
fedirjh previously approved these changes Dec 15, 2022
@@ -10,7 +10,6 @@ import compose from '../../compose';
import * as PersonalDetails from '../../actions/PersonalDetails';
import * as Pusher from '../../Pusher/pusher';
import PusherConnectionManager from '../../PusherConnectionManager';
import UnreadIndicatorUpdater from '../../UnreadIndicatorUpdater';
import ROUTES from '../../../ROUTES';
Copy link
Contributor

Choose a reason for hiding this comment

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

changes looks good

puneetlath
puneetlath previously approved these changes Dec 15, 2022
Copy link
Contributor

@puneetlath puneetlath left a comment

Choose a reason for hiding this comment

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

It looks good to me, but @tgolen it looks like you have some unit tests failing.

@sobitneupane will you be able to review/test this PR in the next day?

@tgolen
Copy link
Contributor Author

tgolen commented Dec 15, 2022

OK, I'll look into those unit tests.

@sobitneupane
Copy link
Contributor

Screenshots/Videos

Web
Screen.Recording.2022-12-16.at.18.14.54.mov
Mobile Web - Chrome
Screen.Recording.2022-12-17.at.10.32.44.mov
Mobile Web - Safari
Screen.Recording.2022-12-17.at.10.26.22.mov
Desktop
Screen.Recording.2022-12-17.at.10.21.19.mov
iOS
Screen.Recording.2022-12-16.at.18.22.05.mov
Android
Screen.Recording.2022-12-16.at.18.57.03.mov

@tgolen
Copy link
Contributor Author

tgolen commented Dec 19, 2022

@tgolen I am getting following console error.

OK, I'm not sure how that can happen, but I've added a check for a null report object now which should prevent that from happening.

@puneetlath
Copy link
Contributor

@sobitneupane are you able to test again?

@sobitneupane
Copy link
Contributor

@tgolen With the latest change, when we reload the page after sign out (or close the tab and reopen expensify on new tab after signout), the unread count reappears.

Tested with the following account:
email: applausetester+0901abb@applause.expensifail.com
Password: Feya86Katya

I was able to reproduce the issue on chrome only (not on firefox, safari and chrome incognito).

@tgolen
Copy link
Contributor Author

tgolen commented Dec 20, 2022

OK, thanks for reporting that. Let me look into that. That's really strange.

@tgolen
Copy link
Contributor Author

tgolen commented Dec 20, 2022

I tried to reproduce it, and I couldn't reproduce it in Chrome on either MacOS or Android mobile web. This is what I did:

  1. Sign into an account that has an unread chat
  2. Verify the title shows there is an unread chat
  3. Sign out
  4. Verify the title shows 0 unread chats
  5. Refresh
  6. Verify the title still shows 0 unread chats

I'm going to remerge main into this branch just to see if that helps you. Please make sure to do a fresh npm i before testing it again.

@sobitneupane
Copy link
Contributor

sobitneupane commented Dec 20, 2022

I was able to reproduce similar issue in staging as well.

When I log out from one account and login to another account, reports from logged out account also appears in the newly logged in account.

For example, in the following picture reports in LHN with red capsule do not belong to currently logged in user.

Screenshot 2022-12-21 at 00 40 24

So, I think #13600 (comment) bug is also caused by the same issue.

@tgolen
Copy link
Contributor Author

tgolen commented Dec 20, 2022

I don't think I'm following you. The changes in this PR can't affect anything on staging, so the changes here should only improve any problems you saw on staging.

@sobitneupane
Copy link
Contributor

I mean to say #13600 (comment) and #13600 (comment) bug might be caused by same issue. And might not be related to this PR. I will report it in expensify-bug channel to see if any other user has seen the similar bug.

@sobitneupane
Copy link
Contributor

Screen.Recording.2022-12-21.at.01.04.57.mov

@puneetlath
Copy link
Contributor

@sobitneupane so are you still seeing issues with this PR or no?

I just tried testing on Chrome and wasn't able to reproduce the issue.

@sobitneupane
Copy link
Contributor

@puneetlath Yes, I am still reproduce #13600 (comment) issue. Interestingly, I can only reproduce it on chrome non-incognito.

@tgolen
Copy link
Contributor Author

tgolen commented Dec 20, 2022

Hm, I was definitely also testing it in chrom non-icognito. When I first tried to reproduce it, I thought it happened, but then I had some errors in the JS console about missing libs, and that's when I ended up remerging main into the branch and restarting webpack. That made the errors go away and I could no longer reproduce it at all.

@fedirjh
Copy link
Contributor

fedirjh commented Dec 20, 2022

@tgolen I haven't tested these changes yet , but what I see in @sobitneupane video I can see where the bug is . i can tell that this is related to both onyx clear logic which delay clearing and the fact that you have imported the subscriber in the whole App . The subsriber should be imported in AuthScreen . Because when he refresh before onyx finish , the data that wasn't cleared will be used by onyx and the subscriber will be triggered again (we have data and subscriber is imported) a fix for this will be to import subscriber on AuthScreen and/or to close the subscriber connection after logout

import subscriber on AuthScreen instead of globally import

Edit: I think this is enough to fix the issue

@fedirjh
Copy link
Contributor

fedirjh commented Dec 21, 2022

@tgolen as yo can see here the subscriber callback is called on guest screen when Onyx have data (unfinished clearing)

Screen.Recording.2022-12-21.at.1.27.24.PM.mov

@tgolen
Copy link
Contributor Author

tgolen commented Dec 28, 2022

@fedirjh Thanks for those comments! I think it's perfectly fine to have the subscriber where it is. Shouldn't we be more concerned with why there is still report data in Onyx after signing out? That seems to be the root of the issue.

@tgolen
Copy link
Contributor Author

tgolen commented Dec 28, 2022

Today I tried to reproduce the issue with a large account. I've got an account with 4000 reports and 4000 users, and I wasn't able to reproduce the issue of Onyx not clearing out all the data. I think we need to try and zero-in on how exactly to reproduce that and treat it as a separate issue. Though, I also saw that we are reverting some of the changes to Onyx.clear(), so we might want to hold off on doing anything until we know what the final state of Onyx.clear() will be.

For this PR, I think the changes are good and will remain good regardless of what happens to fix Onyx.clear().

@sobitneupane
Copy link
Contributor

We have new issue to handle issues like this. I think we can move forward this this PR.

@puneetlath Overall change looks good to me.

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

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

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

@puneetlath puneetlath merged commit 1e539c9 into main Dec 30, 2022
@puneetlath puneetlath deleted the tgolen-fix-unread-count-on-signout branch December 30, 2022 17:06
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Jan 2, 2023

🚀 Deployed to staging by @puneetlath in version: 1.2.47-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Jan 4, 2023

🚀 Deployed to production by @roryabraham in version: 1.2.47-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants