-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30852 from Expensify/revert-28469-perf/refactor-h…
…eavy-operations-for-draft [NoQA] Revert "perf: refactor heavy operations when user starts to type"
- Loading branch information
Showing
9 changed files
with
24 additions
and
82 deletions.
There are no files selected for viewing
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,38 +1,15 @@ | ||
import {InteractionManager} from 'react-native'; | ||
import Onyx from 'react-native-onyx'; | ||
import _ from 'underscore'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import updateUnread from './updateUnread/index'; | ||
|
||
let previousUnreadCount = 0; | ||
|
||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
waitForCollectionCallback: true, | ||
callback: (reportsFromOnyx) => { | ||
if (!reportsFromOnyx) { | ||
return; | ||
} | ||
|
||
/** | ||
* We need to wait until after interactions have finished to update the unread count because otherwise | ||
* the unread count will be updated while the interactions/animations are in progress and we don't want | ||
* to put more work on the main thread. | ||
* | ||
* For eg. On web we are manipulating DOM and it makes it a better candidate to wait until after interactions | ||
* have finished. | ||
* | ||
* More info: https://reactnative.dev/docs/interactionmanager | ||
*/ | ||
InteractionManager.runAfterInteractions(() => { | ||
const unreadReports = _.filter(reportsFromOnyx, (report) => ReportUtils.isUnread(report) && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN); | ||
const unreadReportsCount = _.size(unreadReports); | ||
if (previousUnreadCount !== unreadReportsCount) { | ||
previousUnreadCount = unreadReportsCount; | ||
updateUnread(unreadReportsCount); | ||
} | ||
}); | ||
const unreadReports = _.filter(reportsFromOnyx, (report) => ReportUtils.isUnread(report) && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN); | ||
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