Keep a continued draft on screen, ask before Edit drops rewritten copy, and retry clearing the draft after publish.
This commit is contained in:
1 parent
54a4871ad1
commit
7c08766092
11 files changed
+361
-41
No files matched your search
@@ -18,6 +18,15 @@ import {
|
||||
} from "../utils/flowSteps";
|
||||
import { createFlowStepPath } from "../utils/createFlowPaths";
|
||||
|
||||
const DRAFT_DELETE_ATTEMPTS = 3;
|
||||
|
||||
/** The rule is saved. Keep trying until the source draft is actually gone. */
|
||||
async function deleteServerDraftAfterPublish(): Promise<void> {
|
||||
for (let attempt = 0; attempt < DRAFT_DELETE_ATTEMPTS; attempt += 1) {
|
||||
if (await deleteServerDraft()) return;
|
||||
}
|
||||
}
|
||||
|
||||
type AppRouterLike = { push: (_href: string) => void };
|
||||
|
||||
type OpenLogin = (args: {
|
||||
@@ -154,7 +163,7 @@ export function useCreateFlowFinalize({
|
||||
document: ruleDocument,
|
||||
});
|
||||
updateState({ editingPublishedRuleId: undefined });
|
||||
void deleteServerDraft();
|
||||
void deleteServerDraftAfterPublish();
|
||||
router.push(createFlowStepPath("completed"));
|
||||
return;
|
||||
}
|
||||
@@ -209,7 +218,7 @@ export function useCreateFlowFinalize({
|
||||
writePendingKeepRuleLogin();
|
||||
onGuestPublished?.({ skippedInvites: skippedGuestInvites });
|
||||
} else {
|
||||
void deleteServerDraft();
|
||||
void deleteServerDraftAfterPublish();
|
||||
}
|
||||
router.push(
|
||||
createFlowStepPath("completed", {
|
||||
|
||||
Reference in new issue
Block a user