-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
13a7b96
Remove unnecessary method
tgolen 8083313
WIP on cleaning up unread report counter
tgolen 38d81be
Update version of Onyx
tgolen 069c338
Update page title after JS is done running
tgolen dedbdb2
Update podfile lock too
tgolen f23efa1
Remove some debug code
tgolen d68cd57
Remove unused imports
tgolen 22a942b
Remove unused import
tgolen 1091618
Remove unused import
tgolen e43d8af
Remove unused import
tgolen 99f7c57
Import the lib for updating the unread count
tgolen c6039ff
Merge branch 'main' into tgolen-fix-unread-count-on-signout
tgolen dff42c6
Fix failing tests
tgolen 4f7ea06
Protect against null reports
tgolen 06bf8f4
Merge branch 'main' into tgolen-fix-unread-count-on-signout
tgolen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,14 @@ | ||
import _ from 'underscore'; | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import updateUnread from './updateUnread'; | ||
import updateUnread from './updateUnread/index'; | ||
import * as ReportUtils from '../ReportUtils'; | ||
|
||
const reports = {}; | ||
|
||
/** | ||
* Updates the title and favicon of the current browser tab and Mac OS or iOS dock icon with an unread indicator. | ||
* Note: We are throttling this since listening for report changes can trigger many updates depending on how many reports | ||
* a user has and how often they are updated. | ||
*/ | ||
const throttledUpdatePageTitleAndUnreadCount = _.throttle(() => { | ||
const totalCount = _.filter(reports, ReportUtils.isUnread).length; | ||
updateUnread(totalCount); | ||
}, 100, {leading: false}); | ||
|
||
let connectionID; | ||
|
||
/** | ||
* Bind to the report collection key and update | ||
* the title and unread count indicators | ||
*/ | ||
function listenForReportChanges() { | ||
connectionID = Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
callback: (report) => { | ||
if (!report || !report.reportID) { | ||
return; | ||
} | ||
|
||
reports[report.reportID] = report; | ||
throttledUpdatePageTitleAndUnreadCount(); | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* Remove the subscription callback when we no longer need it. | ||
*/ | ||
function stopListeningForReportChanges() { | ||
if (!connectionID) { | ||
return; | ||
} | ||
|
||
Onyx.disconnect(connectionID); | ||
} | ||
|
||
export default { | ||
listenForReportChanges, | ||
stopListeningForReportChanges, | ||
throttledUpdatePageTitleAndUnreadCount, | ||
}; | ||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
waitForCollectionCallback: true, | ||
callback: (reportsFromOnyx) => { | ||
const unreadReports = _.filter(reportsFromOnyx, ReportUtils.isUnread); | ||
updateUnread(_.size(unreadReports)); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
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.
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.
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.
changes looks good