-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add mark all reports as read shortcut #61753
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
Changes from all commits
41e3e8d
9e6bb58
6e170c9
21e682b
49bee39
baf31a4
d854964
e71a101
8ed969e
488aaa8
7b5c718
a214e0a
fb9206a
ff07fce
aa33bda
a0eefb6
cf7c1f9
049ac68
0c3255a
34291e0
1208ed7
a9e6f57
fa3d50a
30080b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| type MarkAllMessagesAsReadParams = { | ||
| reportIDList: string[]; | ||
| }; | ||
|
|
||
| export default MarkAllMessagesAsReadParams; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,7 @@ import type { | |||||||||||||||||||||||||||||||||||||||||
| InviteToGroupChatParams, | ||||||||||||||||||||||||||||||||||||||||||
| InviteToRoomParams, | ||||||||||||||||||||||||||||||||||||||||||
| LeaveRoomParams, | ||||||||||||||||||||||||||||||||||||||||||
| MarkAllMessagesAsReadParams, | ||||||||||||||||||||||||||||||||||||||||||
| MarkAsExportedParams, | ||||||||||||||||||||||||||||||||||||||||||
| MarkAsUnreadParams, | ||||||||||||||||||||||||||||||||||||||||||
| MoveIOUReportToExistingPolicyParams, | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -144,6 +145,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||
| isIOUReportUsingReport, | ||||||||||||||||||||||||||||||||||||||||||
| isMoneyRequestReport, | ||||||||||||||||||||||||||||||||||||||||||
| isSelfDM, | ||||||||||||||||||||||||||||||||||||||||||
| isUnread, | ||||||||||||||||||||||||||||||||||||||||||
| isValidReportIDFromPath, | ||||||||||||||||||||||||||||||||||||||||||
| prepareOnboardingOnyxData, | ||||||||||||||||||||||||||||||||||||||||||
| } from '@libs/ReportUtils'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1607,6 +1609,66 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| function markAllMessagesAsRead() { | ||||||||||||||||||||||||||||||||||||||||||
| if (isAnonymousUser()) { | ||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const newLastReadTime = DateUtils.getDBTimeWithSkew(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| type PartialReport = { | ||||||||||||||||||||||||||||||||||||||||||
| lastReadTime: Report['lastReadTime'] | null; | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
| const optimisticReports: Record<string, PartialReport> = {}; | ||||||||||||||||||||||||||||||||||||||||||
| const failureReports: Record<string, PartialReport> = {}; | ||||||||||||||||||||||||||||||||||||||||||
| const reportIDList: string[] = []; | ||||||||||||||||||||||||||||||||||||||||||
| Object.values(allReports ?? {}).forEach((report) => { | ||||||||||||||||||||||||||||||||||||||||||
| if (!report) { | ||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID( | ||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bernhardoj Is there a reason for doing this? Is there a problem if we mark both report and expense as read in one-transaction view?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if you mark the transaction thread as read, then App/src/libs/ReportActionsUtils.ts Lines 1333 to 1336 in 515655a
Getting the transaction thread for a one-transaction report is useful when getting the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bernhardoj Can you mark the code where I can identify this case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the code. Lines 8657 to 8667 in a0f0159
Lines 11675 to 11679 in a0f0159
|
||||||||||||||||||||||||||||||||||||||||||
| report.reportID, | ||||||||||||||||||||||||||||||||||||||||||
| allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`], | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
| const oneTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oneTransactionThreadReportID}`]; | ||||||||||||||||||||||||||||||||||||||||||
| if (!isUnread(report, oneTransactionThreadReport)) { | ||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const reportKey = `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`; | ||||||||||||||||||||||||||||||||||||||||||
| optimisticReports[reportKey] = {lastReadTime: newLastReadTime}; | ||||||||||||||||||||||||||||||||||||||||||
| failureReports[reportKey] = {lastReadTime: report.lastReadTime ?? null}; | ||||||||||||||||||||||||||||||||||||||||||
| reportIDList.push(report.reportID); | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if (reportIDList.length === 0) { | ||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const optimisticData = [ | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| onyxMethod: Onyx.METHOD.MERGE_COLLECTION, | ||||||||||||||||||||||||||||||||||||||||||
| key: ONYXKEYS.COLLECTION.REPORT, | ||||||||||||||||||||||||||||||||||||||||||
| value: optimisticReports, | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const failureData = [ | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| onyxMethod: Onyx.METHOD.MERGE_COLLECTION, | ||||||||||||||||||||||||||||||||||||||||||
| key: ONYXKEYS.COLLECTION.REPORT, | ||||||||||||||||||||||||||||||||||||||||||
| value: failureReports, | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const parameters: MarkAllMessagesAsReadParams = { | ||||||||||||||||||||||||||||||||||||||||||
| reportIDList, | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| API.write(WRITE_COMMANDS.MARK_ALL_MESSAGES_AS_READ, parameters, {optimisticData, failureData}); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Sets the last read time on a report | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -5585,6 +5647,7 @@ export { | |||||||||||||||||||||||||||||||||||||||||
| openReportFromDeepLink, | ||||||||||||||||||||||||||||||||||||||||||
| openRoomMembersPage, | ||||||||||||||||||||||||||||||||||||||||||
| readNewestAction, | ||||||||||||||||||||||||||||||||||||||||||
| markAllMessagesAsRead, | ||||||||||||||||||||||||||||||||||||||||||
| removeFromGroupChat, | ||||||||||||||||||||||||||||||||||||||||||
| removeFromRoom, | ||||||||||||||||||||||||||||||||||||||||||
| resolveActionableMentionWhisper, | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.