-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix/39049 shortcut self dm task #39215
Changes from 9 commits
dbb8c41
aac0bfc
1f8b24d
e211c64
d22e7ad
c77c635
17f17ef
7c9249e
52e1364
71f2766
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -652,23 +652,32 @@ function setAssigneeChatReport(chatReport: OnyxTypes.Report) { | |
* If there is no existing chat, it creates an optimistic chat report | ||
* It also sets the shareDestination as that chat report if a share destination isn't already set | ||
*/ | ||
function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shareDestination: string, isCurrentUser = false): OnyxEntry<OnyxTypes.Report> { | ||
let chatReport: OnyxEntry<OnyxTypes.Report> = null; | ||
|
||
function setAssigneeValue( | ||
assigneeEmail: string, | ||
assigneeAccountID: number, | ||
shareToReportID: string, | ||
chatReport: OnyxEntry<OnyxTypes.Report>, | ||
isCurrentUser = false, | ||
): OnyxEntry<OnyxTypes.Report> { | ||
let report = chatReport; | ||
if (!isCurrentUser) { | ||
chatReport = ReportUtils.getChatByParticipants([assigneeAccountID]); | ||
if (!chatReport) { | ||
chatReport = ReportUtils.buildOptimisticChatReport([assigneeAccountID]); | ||
chatReport.isOptimisticReport = true; | ||
// Check for the chatReport by participants IDs | ||
if (!report) { | ||
report = ReportUtils.getChatByParticipants([assigneeAccountID]); | ||
} | ||
// If chat report is still not found we need to build new optimistic chat report | ||
if (!report) { | ||
report = ReportUtils.buildOptimisticChatReport([assigneeAccountID]); | ||
report.isOptimisticReport = true; | ||
|
||
// When assigning a task to a new user, by default we share the task in their DM | ||
// However, the DM doesn't exist yet - and will be created optimistically once the task is created | ||
// We don't want to show the new DM yet, because if you select an assignee and then change the assignee, the previous DM will still be shown | ||
// So here, we create it optimistically to share it with the assignee, but we have to hide it until the task is created | ||
if (chatReport) { | ||
chatReport.isHidden = true; | ||
if (report) { | ||
report.isHidden = true; | ||
} | ||
Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, chatReport); | ||
Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); | ||
|
||
// If this is an optimistic report, we likely don't have their personal details yet so we set it here optimistically as well | ||
const optimisticPersonalDetailsListAction = { | ||
|
@@ -680,12 +689,12 @@ function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shar | |
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[assigneeAccountID]: optimisticPersonalDetailsListAction}); | ||
} | ||
|
||
setAssigneeChatReport(chatReport); | ||
setAssigneeChatReport(report); | ||
|
||
// If there is no share destination set, automatically set it to the assignee chat report | ||
// This allows for a much quicker process when creating a new task and is likely the desired share destination most times | ||
if (!shareDestination) { | ||
setShareDestinationValue(chatReport?.reportID ?? ''); | ||
if (!shareToReportID) { | ||
setShareDestinationValue(report?.reportID ?? ''); | ||
} | ||
} | ||
|
||
|
@@ -695,7 +704,7 @@ function setAssigneeValue(assigneeEmail: string, assigneeAccountID: number, shar | |
// When we're editing the assignee, we immediately call editTaskAssignee. Since setting the assignee is async, | ||
// the chatReport is not yet set when editTaskAssignee is called. So we return the chatReport here so that | ||
// editTaskAssignee can use it. | ||
return chatReport; | ||
return report; | ||
} | ||
|
||
/** | ||
|
@@ -709,14 +718,14 @@ function setParentReportID(parentReportID: string) { | |
/** | ||
* Clears out the task info from the store and navigates to the NewTaskDetails page | ||
*/ | ||
function clearOutTaskInfoAndNavigate(reportID: string, accountID = 0) { | ||
function clearOutTaskInfoAndNavigate(reportID: string, report: OnyxEntry<OnyxTypes.Report>, accountID = 0) { | ||
clearOutTaskInfo(); | ||
if (reportID && reportID !== '0') { | ||
setParentReportID(reportID); | ||
} | ||
if (accountID > 0) { | ||
const accountLogin = allPersonalDetails?.[accountID]?.login ?? ''; | ||
setAssigneeValue(accountLogin, accountID, reportID); | ||
setAssigneeValue(accountLogin, accountID, reportID, report); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
} | ||
Navigation.navigate(ROUTES.NEW_TASK_DETAILS); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,7 +178,7 @@ function FloatingActionButtonAndPopover(props) { | |
IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID); | ||
return; | ||
case CONST.QUICK_ACTIONS.ASSIGN_TASK: | ||
Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, _.get(props.quickAction, 'targetAccountID', 0)); | ||
Task.clearOutTaskInfoAndNavigate(props.quickAction.chatReportID, quickActionReport, _.get(props.quickAction, 'targetAccountID', 0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should had passed
This caused #44388 |
||
return; | ||
default: | ||
return ''; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry but why do we need the both report and reportid cant we just use report.reportID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually sometime report is null but reportID can be
task.shareDestination
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please find related discussion here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense! but lets call it chatReport instead