mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-05 00:14:18 +00:00
fix: go to the contacts or calendar import from a file's preview instead of staying in Files
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user