Skip to content

[stable-0.1] fix(viewer): no overlapping saves, Ctrl+S everywhere, no fallback to the previous file - #460

Merged
AndyScherzinger merged 3 commits into
stable-0.1from
backport/viewer-save-hotkey/stable-0.1
Oct 27, 2026
Merged

AndyScherzinger merged 3 commits into
stable-0.1from
backport/viewer-save-hotkey/stable-0.1

Conversation

@AndyScherzinger

Copy link
Copy Markdown
Member

Backport of #459 for Nextcloud 32–35, plus one fix that only applies to this line. Based on the analysis of #259 (thanks @stephancordes for the diagnosis).

  • No overlapping saves: cherry-picked unchanged from fix(viewer): no overlapping saves, Ctrl+S saves wherever the focus is #459. A save requested while one is running waits and runs afterwards, instead of failing the mtime check with "updated in the meantime".
  • Ctrl+S wherever the focus is: the editor part is the same as in fix(viewer): no overlapping saves, Ctrl+S saves wherever the focus is #459. The parent part is adapted: on this line the viewer handler is the Vue component, so it listens in mounted and stops in beforeDestroy (Vue 2.7, as the viewer app runs it) and beforeUnmount (Vue 3, the test environment).
  • No fallback to the previous file (0.1.x only, main no longer has the file lookup): the component looks the opened file up in the viewer's file list. When it isn't there yet, setFile() threw on undefined and left the previous file in place, so the editor loaded that map and autosave wrote to it while the viewer showed the new file's name. setFile() now forgets the previous file, so loading fails with "Could not load the file" and the viewer closes.

Checked: unit tests (122 passing, 4 new), lint. Not yet tested on a live instance.

Note: src/__tests__/MindMap.spec.js and src/__tests__/mindmap.spec.js differ only in case on this branch, so a checkout on Windows or macOS keeps only one of them. Main avoids that with mindmapElement.spec.js.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

Autosave runs every 10 seconds next to the save button and Ctrl+S. When
two saves overlapped, the second request still carried the old mtime and
failed with "The file you are working on was updated in the meantime",
although nobody else had touched the file.

A save requested while one is running now waits for it and runs
afterwards, so edits made in between are saved as well and a pending
close still gets its answer. The map is marked unchanged when the
request goes out and changed again when it fails, so edits made during
a save are no longer lost.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
(cherry picked from commit ea2776d)
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger AndyScherzinger added this to the v0.1.6 milestone Oct 27, 2026
@AndyScherzinger AndyScherzinger added bug Something isn't working AI assisted This PR contains AI-assisted commits 3. to review labels Oct 27, 2026
Inside the editor, Ctrl+S was handled in the bubble phase, where the
editor's own key handlers could swallow it first. It is now handled in
the capture phase and checks event.key instead of the deprecated
event.which.

With the focus outside the editor iframe, for example on the viewer's
header, Ctrl+S opened the browser's save dialog. The viewer component
now catches it while it is shown and asks the editor to save.

Backport of 4b99f03 from main, where the viewer handler is a custom
element; here the same handling lives in the Vue component.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The viewer component looks the opened file up in the viewer's file
list. When it is not there yet, setFile() got undefined and threw on
file.filename, leaving the editor with the previously opened file: it
then loaded that map, and autosave wrote to it, while the viewer showed
the new file's name.

setFile() now forgets the previous file in that case, so loading fails
with "Could not load the file" and the viewer closes.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger
AndyScherzinger merged commit b6f3dd4 into stable-0.1 Oct 27, 2026
7 checks passed
@AndyScherzinger
AndyScherzinger deleted the backport/viewer-save-hotkey/stable-0.1 branch October 27, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant