Skip to content

Commit b46aaf7

Browse files
juliusmarmingecodex
andcommitted
Return missing share projects to picker
Co-authored-by: codex <[email protected]>
1 parent ac59b0e commit b46aaf7

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export function NewTaskDraftScreen(props: {
101101
const [importingShareKey, setImportingShareKey] = useState<string | null>(null);
102102
const [isCancellingShareImport, setIsCancellingShareImport] = useState(false);
103103
const [cancelledIncomingShareId, setCancelledIncomingShareId] = useState<string | null>(null);
104+
const [isReturningToProjectPicker, setIsReturningToProjectPicker] = useState(false);
104105
const [shareImportAttempt, setShareImportAttempt] = useState(0);
105106
const startedShareImportKeyRef = useRef<string | null>(null);
106107
const cancellingShareImportKeyRef = useRef<string | null>(null);
@@ -117,7 +118,10 @@ export function NewTaskDraftScreen(props: {
117118
const isIncomingShareTransferPending = Boolean(
118119
incomingShare && cancelledIncomingShareId !== props.incomingShareId,
119120
);
120-
usePreventRemove(isIncomingShareTransferPending || isCancellingShareImport, () => undefined);
121+
usePreventRemove(
122+
(isIncomingShareTransferPending && !isReturningToProjectPicker) || isCancellingShareImport,
123+
() => undefined,
124+
);
121125
const hasImportedIncomingShare = Boolean(
122126
props.incomingShareId &&
123127
flow.draftKey &&
@@ -139,6 +143,19 @@ export function NewTaskDraftScreen(props: {
139143
navigation.goBack();
140144
}
141145
}, [cancelledIncomingShareId, navigation, props.incomingShareId]);
146+
useEffect(() => {
147+
if (!isReturningToProjectPicker) {
148+
return;
149+
}
150+
// Let usePreventRemove commit its disabled state before replacing this
151+
// route, otherwise the transfer guard can swallow the fallback action.
152+
const frame = requestAnimationFrame(() => {
153+
navigation.dispatch(
154+
StackActions.replace("NewTask", { incomingShareId: props.incomingShareId }),
155+
);
156+
});
157+
return () => cancelAnimationFrame(frame);
158+
}, [isReturningToProjectPicker, navigation, props.incomingShareId]);
142159
useEffect(() => {
143160
if (!shareImportMountedRef.current) {
144161
startedShareImportKeyRef.current = null;
@@ -231,9 +248,7 @@ export function NewTaskDraftScreen(props: {
231248
// Never fall through to the flow provider's temporary first-project
232249
// default. Return to the picker with the share id intact so the user
233250
// can choose an available destination.
234-
navigation.dispatch(
235-
StackActions.replace("NewTask", { incomingShareId: props.incomingShareId }),
236-
);
251+
setIsReturningToProjectPicker(true);
237252
}
238253
return;
239254
}

0 commit comments

Comments
 (0)