Open a template from its cards even when a saved draft exists.

This commit is contained in:
adilallo committed 2026-11-22 18:08:34 -07:00
1 parent 851133e56d
commit 55b071aa83
11 files changed
+326 -140

No files matched your search

@@ -11,6 +11,9 @@ import { isBackendSyncEnabled } from "../../../../lib/create/backendSyncEnabled"
*/
export const FRESH_ENTRY_PENDING_KEY = "create:fresh-entry-pending";
/** Set when a template is applied so server-draft hydration cannot replace it. */
export const TEMPLATE_APPLY_LATCH_KEY = "create:template-apply-latch";
export type PrepareFreshCreateFlowEntryOptions = {
/**
* When `true`, and backend sync is on, also `DELETE /api/drafts/me`.
@@ -28,6 +31,33 @@ export function hasFreshEntryPending(): boolean {
}
}
export function latchTemplateApply(): void {
if (typeof window === "undefined") return;
try {
window.sessionStorage.setItem(TEMPLATE_APPLY_LATCH_KEY, "1");
} catch {
/* ignore — sessionStorage may be unavailable */
}
}
export function hasTemplateApplyLatch(): boolean {
if (typeof window === "undefined") return false;
try {
return window.sessionStorage.getItem(TEMPLATE_APPLY_LATCH_KEY) === "1";
} catch {
return false;
}
}
export function clearTemplateApplyLatch(): void {
if (typeof window === "undefined") return;
try {
window.sessionStorage.removeItem(TEMPLATE_APPLY_LATCH_KEY);
} catch {
/* ignore */
}
}
function setFreshEntryPending(): void {
if (typeof window === "undefined") return;
try {