Skip to content

Commit

Permalink
Add test utility to mark all chats as read
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Oct 18, 2023
1 parent 9e35d91 commit d5466ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/TestToolMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Text from './Text';
import * as User from '../libs/actions/User';
import * as Network from '../libs/actions/Network';
import * as Session from '../libs/actions/Session';
import * as Report from '../libs/actions/Report';
import ONYXKEYS from '../ONYXKEYS';
import Button from './Button';
import TestToolRow from './TestToolRow';
Expand Down Expand Up @@ -94,6 +95,15 @@ function TestToolMenu(props) {
onPress={() => Session.invalidateCredentials()}
/>
</TestToolRow>

{/* Mark all chats as "read". */}
<TestToolRow title="Mark all chats as read">
<Button
small
text="💥"
onPress={() => Report.markAllChatsAsRead()}
/>
</TestToolRow>
</>
);
}
Expand Down
15 changes: 15 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,22 @@ function searchInServer(searchInput) {
debouncedSearchInServer(searchInput);
}

/**
* Test utility used to mark chats as read.
*/
function markAllChatsAsRead() {
// Get all the chats that are unread
_.each(currentReportData, (report, reportID) => {
if (!ReportUtils.isUnread(report)) {
return;
}

readNewestAction(reportID);
});
}

export {
markAllChatsAsRead,
searchInServer,
addComment,
addAttachment,
Expand Down

0 comments on commit d5466ab

Please sign in to comment.