[HOLD for payment 2021-11-04] Don't show drafts in LHN until after a user has left a chat with content still in the compose box.
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Coming off this issue https://github.com/Expensify/App/issues/4615 cc @meetmangukiya , @vitHoracek
Action Performed:
Start typing with a user who is not currently at the top of you LHN
Expected Result:
The LHN doesn't change and move the chat to the top showing you're currently typing a message.
See notes for more context.
Actual Result:
LHN 'flashes' and loads the current chat at the top of LHN, which is distracting and unnecessary.
Platform:
Where is this issue occurring?
- Web
- Desktop App
Notes:
- When someone is composing a text and there are characters in the compose box, 'do nothing'.
- If a users leaves a chat and there are characters still in the box (aka a draft message), then move it up to the top of LHN. That way it wouldn't 'flash' and distract a user when they're in the middle of composing a message. I don't think there's much value in seeing a draft message while you're composing, only once
Version Number: Version 1.0.94-1
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1631062473055500
Triggered auto assignment to @muttmuure (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.
Triggered auto assignment to @Gonals (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
@vitHoracek , didn't want to assign to you but feel free to swap yourself out for @Gonals and/or the CME if you want.
@meetmangukiya will have 'first dibs' on fixing this issue because they completed the other, related issue and have confirmed they're interested in working on this improvement to the original issue.
@mallenexpensify Thank you, I can take it on since I have the context from the issue this came from.
This can be worked on by External contributor.
@meetmangukiya can you submit a proposal here so I can hire you? And confirm in a comment here once you have? https://www.upwork.com/jobs/~0188b3f5cc094d8f7e
Triggered auto assignment to @Beamanator (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Sorry @Beamanator , @mountiny's got this one. He must not officially be on the CME team which is why you were added.
Applied on upwork @mallenexpensify
Proposal
If we want to Hide the Draft pencil icon until the user is active on the report and stop it from flashing from the sidebar.
- Pass a new argument to the
CreateOptionMethod named asactiveReportID. - Update the
hasDraftCommentCheck in thecreateOptionhttps://github.com/Expensify/App/blob/01f351c41f59c1c991d068dd0cecca2e34f17d11/src/libs/OptionsListUtils.js#L245.
to
hasDraftComment: (report.reportID !== activeReportID) && _.size(reportDraftComment) > 0,
- Update all instances of CreateOption Call to pass the
activeReportIDparameter.
Note: Sorry, I think I didn't understand the task correctly. Updating the proposal...
If we only want to remove the flash on the sidebar
- We need to update this check so that it does not prioritize the active report. https://github.com/Expensify/App/blob/01f351c41f59c1c991d068dd0cecca2e34f17d11/src/libs/OptionsListUtils.js#L450
if(prioritizeReportsWithDraftComments && reportOption.reportID !== activeReportID && reportOption.hasDraftComment)
@meetmangukiya Could you please provide the proposal here as well? Without that, we cannot hire you. Thank you 🙇
I have seen you have wrote a comment in the issue this came from here, but that cannot be considered as a full proposal unfortunately.
Thank you for your proposal @parasharrajat! We have promised first go for @meetmangukiya as this is coming from an issue they worked on. In the comment linked above, they have proposed slightly different approach then your proposal, so I will see what their written up proposal will look like and then choose the best!
Also @parasharrajat, just to clarify, what we want to achieve here and you have probably understood it in the second updated proposal. We do not want to hide the pencil colour, we basically want to change the moment we reorder the list with a new draft to a moment we switch between reports and not while someone is typing as the flash is distracting.
Just checking in @meetmangukiya before my EOD. Are you still interested in this issue?
Hey @mountiny sorry about the delay and yes, I am. I would try to send a proposal within next 24 hours. Thanks!
Proposal
Add a shouldComponentUpdate method to SidebarLinks.js' SidebarLinks class that will:
- return
trueif active report changes, i.e. reorder can happen if report is switched. - return
trueif any report other than the current report's draft comment changes(added, removed, edited). - return
falseif report draft comments changeset only includes the active report, i.e. no flashing / reordering if only changes in draft comments is to the current report.
shouldComponentUpdate(nextProps) {
const didActiveReportChange = this.props.currentlyViewedReportID !== nextProps.currentlyViewedReportID;
if (didActiveReportChange) {
return true;
}
const previousDraftComments = this.props.draftComments;
const nextDraftComments = nextProps.draftComments;
const previousDraftReports = Object.keys(previousDraftComments);
const nextDraftReports = Object.keys(nextDraftComments);
const reportsWithNewDraftComments = nextDraftReports.filter((report) => {
const isNewDraftComment = !previousDraftReports.includes(report);
const wasNonEmptyDraftComment = previousDraftComments[report] === '';
const hasDraftCommentChanged = previousDraftComments[report] !== nextDraftComments[report];
return isNewDraftComment || (hasDraftCommentChanged && wasNonEmptyDraftComment);
});
const reportsWithRemovedDraftComments = previousDraftReports.filter((report) => {
const isRemovedDraftComment = !nextDraftReports.includes(report);
const isEmptyDraftComment = nextDraftComments[report] === '';
const hasDraftCommentChanged = previousDraftComments[report] !== nextDraftComments[report];
return isRemovedDraftComment || (hasDraftCommentChanged && isEmptyDraftComment);
});
const reportsWithEditedDraftComments = nextDraftReports.filter((report) => {
const didDraftCommentExistPreviously = previousDraftReports.includes(report);
const hasDraftCommentChanged = previousDraftComments[report] !== nextDraftComments[report];
const isNotANewDraftComment = !reportsWithNewDraftComments.includes(report);
const isNotARemovedDraftComment = !reportsWithRemovedDraftComments.includes(report);
return didDraftCommentExistPreviously && hasDraftCommentChanged && isNotANewDraftComment && isNotARemovedDraftComment;
});
const allReportsWithDraftCommentChanges = [
...reportsWithNewDraftComments,
...reportsWithRemovedDraftComments,
...reportsWithEditedDraftComments,
];
const activeReportID = this.props.currentlyViewedReportID;
const reportKey = `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${activeReportID}`;
if (allReportsWithDraftCommentChanges.length === 1 && allReportsWithDraftCommentChanges.includes(reportKey)) {
return false;
}
return true;
}
https://user-images.githubusercontent.com/7620533/133229177-92553b3b-9aaa-4100-9ac9-eaa534fa1ad8.mov
@meetmangukiya Thanks for taking your time to write up the proposal! I see it is quite complex solution compared to the one @parasharrajat provided. I am afraid I would say Rajat's proposal is cleaner and does not introduce so much new code for this update, therefore I would prefer their proposal. At the same time, feel free to come up with different proposal, which you would feel like would be even better than what Rajat has proposed.
@parasharrajat if you are interested, would you be able to write up the proposal in more concise way again, now knowing what exactly we want to achieve? Thank you!
Sorry @mountiny For here and there but there is an issue with my proposal ATM. For this issue, a proposal should work for these points.
- When you are writing a draft, no replacement should happen in the sidebar. :heavy_check_mark:
- When switch the chat, replacement should happen and draft chats should be prioritized. :heavy_check_mark:
- When you click back on the same report with a draft (which was prioritized), no replacement should happen in the sidebar as the report was already prioritized. :red_circle:
- When you clear the draft on the active report, no replacement should happen, and the report should not be deprioritized until you switch the chat. (unknown)
So my proposal won't work. :disappointed:
@parasharrajat Thank you for clarifying this! I appreciate that.
@meetmangukiya In that case, seems like there won't be many easy solutions for this. I will wait one more day to see if anyone (or feel free to think about this too) comes up with something more clearer. Otherwise it will be yours!
Alright, as there has been no new proposals added, I am happy to proceed with @meetmangukiya proposal.
@mallenexpensify I know this is on hold, ubt I think @meetmangukiya should be good to start work on this and testing properly so they have a PR ready once we take issues off n6-hold. @meetmangukiya feel free to apply for the job on Upwork and @mallenexpensify can you please hire Meet? Thank youuu 🙇
As we are prioritizing the n6 release, we apologize for any delays in communication.
Hired @meetmangukiya in Upwork!