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

[HOLD] Revert "Refactor code to improve unread marker logic" #25785

Closed
wants to merge 1 commit 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
39 changes: 6 additions & 33 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ Onyx.connect({
},
});

const currentReportData = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
callback: (data, key) => {
if (!key || !data) {
return;
}
const reportID = CollectionUtils.extractCollectionItemID(key);
currentReportData[reportID] = data;
},
});

let isNetworkOffline = false;
Onyx.connect({
key: ONYXKEYS.NETWORK,
Expand Down Expand Up @@ -385,10 +373,6 @@ function addComment(reportID, text) {
addActions(reportID, text);
}

function reportActionsExist(reportID) {
return allReportActions[reportID] !== undefined;
}

/**
* Gets the latest page of report actions and updates the last read message
* If a chat with the passed reportID is not found, we will create a chat based on the passed participantList
Expand All @@ -404,13 +388,11 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p
const optimisticReportData = {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: reportActionsExist(reportID)
? {}
: {
isLoadingReportActions: true,
isLoadingMoreReportActions: false,
reportName: lodashGet(allReports, [reportID, 'reportName'], CONST.REPORT.DEFAULT_REPORT_NAME),
},
value: {
isLoadingReportActions: true,
isLoadingMoreReportActions: false,
lastReadTime: DateUtils.getDBTime(),
},
};
const reportSuccessData = {
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -538,8 +520,6 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p
}
}

params.clientLastReadTime = lodashGet(currentReportData, [reportID, 'lastReadTime'], '');

if (isFromDeepLink) {
// eslint-disable-next-line rulesdir/no-api-side-effects-method
API.makeRequestWithSideEffects('OpenReport', params, onyxData).finally(() => {
Expand Down Expand Up @@ -740,20 +720,18 @@ function expandURLPreview(reportID, reportActionID) {
* @param {String} reportID
*/
function readNewestAction(reportID) {
const lastReadTime = DateUtils.getDBTime();
API.write(
'ReadNewestAction',
{
reportID,
lastReadTime,
},
{
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
lastReadTime,
lastReadTime: DateUtils.getDBTime(),
},
},
],
Expand Down Expand Up @@ -1774,10 +1752,6 @@ function openReportFromDeepLink(url, isAuthenticated) {
});
}

function getCurrentUserAccountID() {
return currentUserAccountID;
}

/**
* Leave a report by setting the state to submitted and closed
*
Expand Down Expand Up @@ -1977,7 +1951,6 @@ export {
hasAccountIDEmojiReacted,
shouldShowReportActionNotification,
leaveRoom,
getCurrentUserAccountID,
setLastOpenedPublicRoom,
flagComment,
openLastOpenedPublicRoom,
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class ReportScreen extends React.Component {
if (this.props.report.reportID && this.props.report.reportID === getReportID(this.props.route)) {
return;
}

Report.openReport(reportIDFromPath);
}

Expand Down
Loading
Loading