( s: Store, oldPath: string, meta: NoteMeta )
| 2696 | } |
| 2697 | |
| 2698 | function renameNoteState( |
| 2699 | s: Store, |
| 2700 | oldPath: string, |
| 2701 | meta: NoteMeta |
| 2702 | ): Partial<Store> { |
| 2703 | const rewrite = (p: string): string => (p === oldPath ? meta.path : p) |
| 2704 | const nextLayout = rewritePathsInTree(s.paneLayout, rewrite) |
| 2705 | const ensured = ensureActivePane(nextLayout, s.activePaneId) |
| 2706 | const contents = { ...s.noteContents } |
| 2707 | const dirty = { ...s.noteDirty } |
| 2708 | const prevContent = contents[oldPath] |
| 2709 | const prevDirty = dirty[oldPath] ?? false |
| 2710 | if (oldPath !== meta.path) { |
| 2711 | delete contents[oldPath] |
| 2712 | delete dirty[oldPath] |
| 2713 | } |
| 2714 | if (prevContent) { |
| 2715 | contents[meta.path] = { ...prevContent, ...meta } |
| 2716 | } |
| 2717 | dirty[meta.path] = prevDirty |
| 2718 | return { |
| 2719 | paneLayout: ensured.layout, |
| 2720 | activePaneId: ensured.activePaneId, |
| 2721 | noteContents: contents, |
| 2722 | noteDirty: dirty, |
| 2723 | notes: replaceNoteMeta(s.notes, oldPath, meta), |
| 2724 | noteBackstack: rewriteNoteJumpHistory(s.noteBackstack, rewrite), |
| 2725 | noteForwardstack: rewriteNoteJumpHistory(s.noteForwardstack, rewrite), |
| 2726 | pendingJumpLocation: |
| 2727 | s.pendingJumpLocation?.path === oldPath |
| 2728 | ? { ...s.pendingJumpLocation, path: meta.path } |
| 2729 | : s.pendingJumpLocation, |
| 2730 | pendingTitleFocusPath: |
| 2731 | s.pendingTitleFocusPath === oldPath ? meta.path : s.pendingTitleFocusPath, |
| 2732 | pinnedRefPath: s.pinnedRefPath === oldPath ? meta.path : s.pinnedRefPath, |
| 2733 | noteComments: rewriteNoteCommentsPath(s.noteComments, oldPath, meta.path), |
| 2734 | activeCommentId: s.activeCommentId, |
| 2735 | ...activeFieldsFrom(ensured.layout, ensured.activePaneId, contents, dirty) |
| 2736 | } |
| 2737 | } |
| 2738 | |
| 2739 | const MAX_DATE_NOTE_PATTERN_HISTORY = 20 |
| 2740 |
no test coverage detected