fix(editor): ask only the top refusing layer, safe retry notes
This commit is contained in:
1 parent
f8be0ad01a
commit
ee86a3a659
5 files changed
+92
-15
No files matched your search
@@ -9,8 +9,9 @@ import { FINGERPRINT_PATTERN, fingerprintOf, randomHex } from './fingerprint'
|
||||
* entries and the left-draft flag carry instead of the account id. It is kept in this
|
||||
* tab's sessionStorage with a fingerprint of the account id salted with the tag, reused
|
||||
* only for the account whose fingerprint it holds, and rotated on sign-out and on any
|
||||
* other account (the flags of the old tag cleared). Resolved at once, on any origin (http included). A storage
|
||||
* that refuses keeps it in memory only: a reload then restores nothing.
|
||||
* other account (the flags of the old tag cleared). Resolved at once, on any origin
|
||||
* (http included). A storage that refuses keeps it in memory only: a reload then
|
||||
* restores nothing.
|
||||
*/
|
||||
const STORAGE_KEY = 'faunosteo:editor:session-tag'
|
||||
const TAG_PATTERN = /^[0-9a-f]{32}$/
|
||||
|
||||
@@ -233,8 +233,8 @@ function leavingLayers(from: EditorView, to: EditorView): LayerName[] {
|
||||
/**
|
||||
* Whether a POP must not be followed, and which layer refused it: a modal that is no
|
||||
* layer is open (its place-scoped state is not in the history, every layer is asked), or
|
||||
* a dirty layer would be removed. Only the layers the POP removes are asked, top down, so
|
||||
* a dirty form shows its own confirmation and a layer the POP keeps is never asked.
|
||||
* a dirty layer would be removed. Only the layers the POP removes are asked, top down, and
|
||||
* the first to refuse stops the walk: a lower dirty layer's question is never left pending.
|
||||
*/
|
||||
function refusal(
|
||||
ctx: PopContext,
|
||||
@@ -246,9 +246,7 @@ function refusal(
|
||||
return 'modal'
|
||||
}
|
||||
const leaving = leavingLayers(view, entry?.view ?? ctx.defaultView)
|
||||
const answers = leaving.map((layer) => nav.guards.ask(layer, false).allowed)
|
||||
const index = answers.indexOf(false)
|
||||
return index < 0 ? null : leaving[index]
|
||||
return leaving.find((layer) => !nav.guards.ask(layer, false).allowed) ?? null
|
||||
}
|
||||
|
||||
/** The view under the finding dialog's sheet: what lies over it is clean, it goes. */
|
||||
|
||||
@@ -86,8 +86,10 @@ export function stepHistory(
|
||||
const state = api.get()
|
||||
const preview = editablePreview(state)
|
||||
if (typeof preview === 'string') return blocked(preview)
|
||||
const move = direction === 'undo' ? stepBack : stepForward
|
||||
const step = move(historyOf(state), state.documentText)
|
||||
const step = (direction === 'undo' ? stepBack : stepForward)(
|
||||
historyOf(state),
|
||||
state.documentText,
|
||||
)
|
||||
if (!step) return blocked('empty')
|
||||
const replaced = preview.replaceDocument(step.text)
|
||||
if (!replaced.ok) return replaced
|
||||
|
||||
Reference in new issue
Block a user