Skip to content

Commit adade48

Browse files
authored
Merge pull request Expensify#67772 from DylanDylann/remove-onyx-connect-in-Task-p1
Remove Onyx.connect() for the key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE in src/libs/actions/Task.ts
2 parents eb1ce69 + 9e28cbe commit adade48

5 files changed

Lines changed: 469 additions & 26 deletions

File tree

src/libs/actions/Task.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ Onyx.connect({
6060
callback: (value) => (allPersonalDetails = value),
6161
});
6262

63-
let quickAction: OnyxEntry<OnyxTypes.QuickAction> = {};
64-
Onyx.connect({
65-
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
66-
callback: (value) => {
67-
quickAction = value;
68-
},
69-
});
70-
7163
let allReportActions: OnyxCollection<ReportActions>;
7264
Onyx.connect({
7365
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
@@ -143,6 +135,7 @@ function createTaskAndNavigate(
143135
assigneeChatReport?: OnyxEntry<OnyxTypes.Report>,
144136
policyID: string = CONST.POLICY.OWNER_EMAIL_FAKE,
145137
isCreatedUsingMarkdown = false,
138+
quickAction: OnyxEntry<OnyxTypes.QuickAction> = {},
146139
) {
147140
if (!parentReportID) {
148141
return;

src/pages/home/report/ReportFooter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function ReportFooter({
9090
const {shouldUseNarrowLayout} = useResponsiveLayout();
9191

9292
const [shouldShowComposeInput = false] = useOnyx(ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT, {canBeMissing: true});
93+
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true});
9394
const [isAnonymousUser = false] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS, canBeMissing: false});
9495
const [isBlockedFromChat] = useOnyx(ONYXKEYS.NVP_BLOCKED_FROM_CHAT, {
9596
selector: (dateString) => {
@@ -159,7 +160,7 @@ function ReportFooter({
159160
title = `@${mentionWithDomain} ${title}`;
160161
}
161162
}
162-
createTaskAndNavigate(report.reportID, title, '', assignee?.login ?? '', assignee?.accountID, assigneeChatReport, report.policyID, true);
163+
createTaskAndNavigate(report.reportID, title, '', assignee?.login ?? '', assignee?.accountID, assigneeChatReport, report.policyID, true, quickAction);
163164
return true;
164165
},
165166
[allPersonalDetails, availableLoginsList, currentUserEmail, report.policyID, report.reportID],

src/pages/tasks/NewTaskDetailsPage.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type NewTaskDetailsPageProps = PlatformStackScreenProps<NewTaskNavigatorParamLis
2828

2929
function NewTaskDetailsPage({route}: NewTaskDetailsPageProps) {
3030
const [task] = useOnyx(ONYXKEYS.TASK, {canBeMissing: true});
31+
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true});
3132
const styles = useThemeStyles();
3233
const {translate} = useLocalize();
3334
const [taskTitle, setTaskTitle] = useState(task?.title ?? '');
@@ -70,7 +71,17 @@ function NewTaskDetailsPage({route}: NewTaskDetailsPageProps) {
7071

7172
if (skipConfirmation) {
7273
setShareDestinationValue(task?.parentReportID);
73-
createTaskAndNavigate(task?.parentReportID, values.taskTitle, values.taskDescription ?? '', task?.assignee ?? '', task.assigneeAccountID, task.assigneeChatReport);
74+
createTaskAndNavigate(
75+
task?.parentReportID,
76+
values.taskTitle,
77+
values.taskDescription ?? '',
78+
task?.assignee ?? '',
79+
task.assigneeAccountID,
80+
task.assigneeChatReport,
81+
CONST.POLICY.OWNER_EMAIL_FAKE,
82+
false,
83+
quickAction,
84+
);
7485
} else {
7586
Navigation.navigate(ROUTES.NEW_TASK.getRoute(backTo));
7687
}

src/pages/tasks/NewTaskPage.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function NewTaskPage({route}: NewTaskPageProps) {
3232
const [task] = useOnyx(ONYXKEYS.TASK, {canBeMissing: true});
3333
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
3434
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
35+
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true});
3536
const styles = useThemeStyles();
3637
const {translate, formatPhoneNumber, localeCompare} = useLocalize();
3738
const assignee = useMemo(() => getAssignee(task?.assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID, personalDetails), [task?.assigneeAccountID, personalDetails]);
@@ -95,7 +96,17 @@ function NewTaskPage({route}: NewTaskPageProps) {
9596
return;
9697
}
9798

98-
createTaskAndNavigate(parentReport?.reportID, task.title, task?.description ?? '', task?.assignee ?? '', task.assigneeAccountID, task.assigneeChatReport, parentReport?.policyID);
99+
createTaskAndNavigate(
100+
parentReport?.reportID,
101+
task.title,
102+
task?.description ?? '',
103+
task?.assignee ?? '',
104+
task.assigneeAccountID,
105+
task.assigneeChatReport,
106+
parentReport?.policyID,
107+
false,
108+
quickAction,
109+
);
99110
};
100111

101112
return (

0 commit comments

Comments
 (0)