fix: go to the contacts or calendar import from a file's preview instead of staying in Files

This commit is contained in:
Linus Rath
2026-11-04 15:05:01 +01:00
parent 2d807b9a66
commit 22edfecddf
2 changed files with 17 additions and 2 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ import { formatRecipient } from "@/lib/email-composer-utils";
import { useRouter } from "@/i18n/navigation";
import { useEditAttachment } from "@/hooks/use-edit-attachment";
import { fileAppAction, type FileAppAction } from "@/lib/files-app-actions";
import { handOffFiles } from "@/lib/launch-handoff";
import { handOffFilesAfterClose } from "@/lib/file-handoff-after-close";
import { ImportEmlDialog } from "@/components/files/import-eml-dialog";
import { useCalendarStore } from "@/stores/calendar-store";
import { resolveConflictsInTurn, type ConflictAnswer, type UploadConflictResolver } from "@/lib/files-upload-conflicts";
@@ -740,7 +740,7 @@ export function FilesApp({ linkSegments: routeSegments }: FilesAppProps = {}) {
}
setPreviewFile(null);
setInfoFile(null);
handOffFiles([file], action === "add-calendar" ? "calendar" : "contacts");
void handOffFilesAfterClose([file], action === "add-calendar" ? "calendar" : "contacts");
}, [appActionOf, getFileContent, t]);
const appActionFor = useCallback((r: FileResource) => {
const action = appActionOf(r);
+15
View File
@@ -0,0 +1,15 @@
import { historySettled } from '@/hooks/use-close-on-back';
import { handOffFiles, type HandoffKind } from '@/lib/launch-handoff';
/**
* Hands files to another app (contacts or calendar import) from a layer that is
* closing, such as the Files preview. Closing it takes its history entry back
* with a Back that lands later; the handoff's move to /contacts or /calendar,
* started before that, was undone by it and left the user in Files (pim-p2-7).
* So: let the close commit, wait for that Back, then hand off.
*/
export async function handOffFilesAfterClose(files: File[], kind: HandoffKind): Promise<void> {
await new Promise<void>((resolve) => setTimeout(resolve, 0));
await historySettled();
handOffFiles(files, kind);
}