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

Fixed Loading spinner on login form and crash after Login #3865

Merged
merged 4 commits into from
Jul 7, 2021
Merged
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
12 changes: 6 additions & 6 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ function createOption(personalDetailList, report, draftComments, {
}) {
const hasMultipleParticipants = personalDetailList.length > 1;
const personalDetail = personalDetailList[0];
const hasDraftComment = report
const reportDraftComment = report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why changing this variable from boolean to object has anything to do with your fixing loading spinner? It looks like it's just used as a boolean below anyway. Can you explain?

Copy link
Member Author

@parasharrajat parasharrajat Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So There are two issues, I am trying to fix in this PR. Sometimes, the lodashGet(draftComments, ${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}, '') returns null. So it will throw an error here that .length is not present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, i see. I didn't expect that value to be null (and hence not use the lodash get default value). Weird. Anyway, thanks for the fix 👍

&& draftComments
&& lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '').length > 0;
&& lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '');

const hasOutstandingIOU = lodashGet(report, 'hasOutstandingIOU', false);
const lastActorDetails = report ? _.find(personalDetailList, {login: report.lastActorEmail}) : null;
Expand Down Expand Up @@ -215,7 +215,7 @@ function createOption(personalDetailList, report, draftComments, {
login: !hasMultipleParticipants ? personalDetail.login : null,
reportID: report ? report.reportID : null,
isUnread: report ? report.unreadActionCount > 0 : null,
hasDraftComment,
hasDraftComment: reportDraftComment && reportDraftComment.length > 0,
keyForList: report ? String(report.reportID) : personalDetail.login,
searchText: getSearchText(report, personalDetailList),
isPinned: lodashGet(report, 'isPinned', false),
Expand Down Expand Up @@ -297,13 +297,13 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
return;
}

const hasDraftComment = report
const reportDraftComment = report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment here. I don't get why this variable change is relevant to your PR.

&& draftComments
&& lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '').length > 0;
&& lodashGet(draftComments, `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, '');

const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0;
const shouldFilterReportIfRead = hideReadReports && report.unreadActionCount === 0;
const shouldShowReportIfHasDraft = showReportsWithDrafts && hasDraftComment;
const shouldShowReportIfHasDraft = showReportsWithDrafts && reportDraftComment && reportDraftComment.length > 0;
const shouldFilterReport = shouldFilterReportIfEmpty || shouldFilterReportIfRead;
if (report.reportID !== activeReportID
&& !report.isPinned
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function resendValidationLink(login = credentials.login) {
function fetchAccountDetails(login) {
Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true});

API.GetAccountStatus({email: login})
API.GetAccountStatus({email: login, forceNetworkRequest: true})
.then((response) => {
if (response.jsonCode === 200) {
Onyx.merge(ONYXKEYS.CREDENTIALS, {
Expand Down