Skip to content

Commit

Permalink
change assigneeAccountID to require param
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed May 6, 2024
1 parent 16282bd commit 8620f63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,8 @@ function setAssigneeChatReport(chatReport: OnyxTypes.Report) {
Onyx.merge(ONYXKEYS.TASK, {assigneeChatReport: chatReport});
}

function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: number | undefined = undefined) {
const currentAssigneeAccountID = assigneeAccountID ?? UserUtils.generateAccountID(assigneeLogin);
const report: ReportUtils.OptimisticChatReport = ReportUtils.buildOptimisticChatReport([currentAssigneeAccountID]);
function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: number) {
const report: ReportUtils.OptimisticChatReport = ReportUtils.buildOptimisticChatReport([assigneeAccountID]);

// 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
Expand All @@ -662,12 +661,12 @@ function setNewOptimisticAssignee(assigneeLogin: string, assigneeAccountID: numb
Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report);

const optimisticPersonalDetailsListAction: OnyxTypes.PersonalDetails = {
accountID: currentAssigneeAccountID,
avatar: allPersonalDetails?.[currentAssigneeAccountID]?.avatar ?? UserUtils.getDefaultAvatarURL(currentAssigneeAccountID),
displayName: allPersonalDetails?.[currentAssigneeAccountID]?.displayName ?? assigneeLogin,
accountID: assigneeAccountID,
avatar: allPersonalDetails?.[assigneeAccountID]?.avatar ?? UserUtils.getDefaultAvatarURL(assigneeAccountID),
displayName: allPersonalDetails?.[assigneeAccountID]?.displayName ?? assigneeLogin,
login: assigneeLogin,
};
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[currentAssigneeAccountID]: optimisticPersonalDetailsListAction});
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {[assigneeAccountID]: optimisticPersonalDetailsListAction});
return {assignee: optimisticPersonalDetailsListAction, assigneeReport: report};
}

Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as ReportUtils from '@libs/ReportUtils';
import * as UserUtils from '@libs/UserUtils';
import variables from '@styles/variables';
import * as Report from '@userActions/Report';
import * as Task from '@userActions/Task';
Expand Down Expand Up @@ -114,7 +115,8 @@ function ReportFooter({
if (mentionWithDomain) {
assignee = Object.values(allPersonalDetails).find((value) => value?.login === mentionWithDomain) ?? {};
if (!Object.keys(assignee).length) {
const optimisticDataForNewAssignee = Task.setNewOptimisticAssignee(mentionWithDomain);
const assigneeAccountID = UserUtils.generateAccountID(mentionWithDomain);
const optimisticDataForNewAssignee = Task.setNewOptimisticAssignee(mentionWithDomain, assigneeAccountID);
assignee = optimisticDataForNewAssignee.assignee;
assigneeChatReport = optimisticDataForNewAssignee.assigneeReport;
}
Expand Down

0 comments on commit 8620f63

Please sign in to comment.