fix(editor): read-only undo, upload session check, restore and submit guards
This commit is contained in:
1 parent
5979cd59ec
commit
05c9b3e10b
20 files changed
+102
-33
No files matched your search
@@ -31,7 +31,7 @@ function replacedPatch(
|
||||
documentText: text,
|
||||
previewState: next,
|
||||
handleVersion: state.handleVersion + 1,
|
||||
unsaved: !sameDocument(text, state.savedText),
|
||||
unsaved: state.staleBase || !sameDocument(text, state.savedText),
|
||||
undo: history.undo,
|
||||
redo: history.redo,
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ export async function submit(api: StoreApi, note?: string): Promise<SubmitOutcom
|
||||
}
|
||||
const reviewId = await submitSheetReview(requireClient(), args)
|
||||
if (api.get().session !== state.session) return blocked('session_changed')
|
||||
api.set({ submitting: false })
|
||||
api.set({ submitting: false, canEdit: false })
|
||||
return { ok: true, reviewId }
|
||||
} catch (error) {
|
||||
return failedSubmit(api, state.session, error)
|
||||
|
||||
@@ -174,7 +174,7 @@ function restoredPatch(
|
||||
next: PreviewState,
|
||||
attached: Attached,
|
||||
): Partial<EditorState> {
|
||||
const text = copyText(copy)
|
||||
const text = JSON.stringify(next.document)
|
||||
return {
|
||||
documentText: text,
|
||||
previewState: next,
|
||||
@@ -183,7 +183,7 @@ function restoredPatch(
|
||||
drawingFailures: { ...now.drawingFailures, ...attached.failures },
|
||||
savedRevision: copy.revision,
|
||||
staleBase: copy.revision < now.savedRevision,
|
||||
unsaved: !sameDocument(text, now.savedText),
|
||||
unsaved: copy.revision < now.savedRevision || !sameDocument(text, now.savedText),
|
||||
...emptyHistory(),
|
||||
...NO_RECOVERY,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user