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

[WIP] Test utility to mark all chats as read #29840

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,21 @@ function searchInServer(searchInput) {
debouncedSearchInServer(searchInput);
}

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

readNewestAction(reportID);
});
}

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