@@ -11,7 +11,6 @@ import { useStore } from '@zennotes/app-core/store'
1111import type { NoteSortOrder } from '@zennotes/app-core/store'
1212import { confirmApp } from '@zennotes/app-core/lib/confirm-requests'
1313import { promptApp } from '@zennotes/app-core/lib/prompt-requests'
14- import { buildMoveNotePrompt , parseMoveNoteTarget } from '@zennotes/app-core/lib/move-note'
1514import { notePathWithinFolder } from '@zennotes/app-core/lib/vault-layout'
1615import { resolveFolderPath } from '@zennotes/shared-domain/system-folder-paths'
1716import {
@@ -26,6 +25,7 @@ import { openMobileSheet } from './sheet-state'
2625import { goHome } from './nav'
2726import { dirOf , noteComparator , pinnedFirst } from './note-order'
2827import { usePins , toggleNotePin , toggleFolderPin } from './pins'
28+ import { archiveNote , openNoteMenu , trashNote } from './note-actions'
2929import { refreshVault } from './refresh'
3030import { SwipeRow } from './SwipeRow'
3131import { getStoragePref } from '../bridge/icloud'
@@ -954,11 +954,11 @@ function MobileDrawerBody(props: {
954954 const lp = useLongPress ( )
955955 const [ sortOpen , setSortOpen ] = useState ( false )
956956 // Long-pressing a row opens its action sheet — the phone's right-click
957- // (Discord folder feedback). Notes mirror the ••• sheet's actions; folders
958- // get Rename/Delete. Prompts overlay the open drawer (Modal layers above
957+ // (Discord folder feedback). Notes open the shell-wide note sheet
958+ // (note-actions.tsx, shared with app-core's lists); folders get
959+ // Rename/Delete here. Prompts overlay the open drawer (Modal layers above
959960 // z-49), so the drawer stays put and its list refreshes in place via the
960961 // vault change events.
961- const [ noteMenu , setNoteMenu ] = useState < { path : string ; title : string } | null > ( null )
962962 const [ folderMenu , setFolderMenu ] = useState < { subpath : string ; name : string } | null > ( null )
963963
964964 const pinNote = ( notePath : string ) : void => {
@@ -1039,46 +1039,6 @@ function MobileDrawerBody(props: {
10391039 }
10401040 } , [ refreshing ] )
10411041
1042- const moveNoteFromDrawer = ( notePath : string ) : void => {
1043- setNoteMenu ( null )
1044- void ( async ( ) => {
1045- const st = s ( )
1046- const meta = st . notes . find ( ( n ) => n . path === notePath )
1047- if ( ! meta ) return
1048- const target = await promptApp ( buildMoveNotePrompt ( meta , st . folders ) )
1049- if ( ! target ) return
1050- const dest = parseMoveNoteTarget ( target )
1051- await s ( ) . moveNote ( meta . path , dest . folder , dest . subpath )
1052- } ) ( )
1053- }
1054-
1055- const renameNoteFromDrawer = ( notePath : string , title : string ) : void => {
1056- setNoteMenu ( null )
1057- void ( async ( ) => {
1058- const next = await promptApp ( {
1059- title : 'Rename note' ,
1060- initialValue : title ,
1061- okLabel : 'Rename' ,
1062- validate : ( v : string ) => ( / [ \\ / ] / . test ( v ) ? 'Title cannot contain / or \\' : null )
1063- } )
1064- if ( ! next || next === title ) return
1065- await s ( ) . renameNote ( notePath , next )
1066- } ) ( )
1067- }
1068-
1069- const archiveNoteFromDrawer = ( notePath : string ) : void => {
1070- setNoteMenu ( null )
1071- void ( async ( ) => {
1072- if ( ! ( await s ( ) . confirmArchiveNotes ( [ notePath ] ) ) ) return
1073- await window . zen . archiveNote ( notePath )
1074- } ) ( )
1075- }
1076-
1077- const copyWikilinkFromDrawer = ( title : string ) : void => {
1078- setNoteMenu ( null )
1079- void navigator . clipboard . writeText ( `[[${ title } ]]` ) . catch ( ( ) => { } )
1080- }
1081-
10821042 const renameFolderFromDrawer = ( subpath : string , name : string ) : void => {
10831043 setFolderMenu ( null )
10841044 void ( async ( ) => {
@@ -1114,18 +1074,6 @@ function MobileDrawerBody(props: {
11141074 } ) ( )
11151075 }
11161076
1117- const trashNote = ( notePath : string , title : string ) : void => {
1118- void ( async ( ) => {
1119- const ok = await confirmApp ( {
1120- title : `Delete "${ title } "?` ,
1121- description : 'It will move to the trash.' ,
1122- confirmLabel : 'Delete' ,
1123- danger : true
1124- } )
1125- if ( ok ) await window . zen . moveToTrash ( notePath )
1126- } ) ( )
1127- }
1128-
11291077 const deleteDatabase = ( subpath : string , title : string ) : void => {
11301078 void ( async ( ) => {
11311079 const ok = await confirmApp ( {
@@ -1331,7 +1279,7 @@ function MobileDrawerBody(props: {
13311279 {
13321280 label : 'Archive' ,
13331281 icon : < Icon d = { D . archive } /> ,
1334- onAction : ( ) => archiveNoteFromDrawer ( n . path )
1282+ onAction : ( ) => archiveNote ( n . path )
13351283 } ,
13361284 {
13371285 label : 'Delete' ,
@@ -1346,7 +1294,7 @@ function MobileDrawerBody(props: {
13461294 < button
13471295 type = "button"
13481296 onClick = { ( ) => go ( ( ) => s ( ) . selectNote ( n . path ) ) }
1349- { ...lp ( ( ) => setNoteMenu ( { path : n . path , title : n . title } ) ) }
1297+ { ...lp ( ( ) => openNoteMenu ( { path : n . path , title : n . title , kind : 'note' } ) ) }
13501298 >
13511299 < Icon d = { D . note } />
13521300 < span className = "zn-truncate" > { n . title } </ span >
@@ -1373,79 +1321,6 @@ function MobileDrawerBody(props: {
13731321 </ div >
13741322 </ div >
13751323
1376- { noteMenu && (
1377- < >
1378- < div
1379- className = "zn-mobile-sheet-backdrop"
1380- onClick = { ( ) => setNoteMenu ( null ) }
1381- role = "presentation"
1382- />
1383- < div className = "zn-mobile-sheet" role = "menu" aria-label = "Note actions" >
1384- < div className = "zn-mobile-sheet-title zn-truncate" > { noteMenu . title } </ div >
1385- < div className = "zn-mobile-sheet-scroll" >
1386- < div className = "zn-mobile-sheet-group" >
1387- < button
1388- type = "button"
1389- className = "zn-mobile-sheet-row"
1390- onClick = { ( ) => {
1391- const p = noteMenu . path
1392- setNoteMenu ( null )
1393- pinNote ( p )
1394- } }
1395- >
1396- < Icon d = { D . pin } />
1397- { pinnedNotes . includes ( noteMenu . path ) ? 'Unpin' : 'Pin' }
1398- </ button >
1399- < button
1400- type = "button"
1401- className = "zn-mobile-sheet-row"
1402- onClick = { ( ) => renameNoteFromDrawer ( noteMenu . path , noteMenu . title ) }
1403- >
1404- < Icon d = { D . rename } />
1405- Rename
1406- </ button >
1407- < button
1408- type = "button"
1409- className = "zn-mobile-sheet-row"
1410- onClick = { ( ) => moveNoteFromDrawer ( noteMenu . path ) }
1411- >
1412- < Icon d = { D . move } />
1413- Move to…
1414- </ button >
1415- < button
1416- type = "button"
1417- className = "zn-mobile-sheet-row"
1418- onClick = { ( ) => copyWikilinkFromDrawer ( noteMenu . title ) }
1419- >
1420- < Icon d = { D . link } />
1421- Copy wikilink
1422- </ button >
1423- < button
1424- type = "button"
1425- className = "zn-mobile-sheet-row"
1426- onClick = { ( ) => archiveNoteFromDrawer ( noteMenu . path ) }
1427- >
1428- < Icon d = { D . archive } />
1429- Archive
1430- </ button >
1431- < button
1432- type = "button"
1433- className = "zn-mobile-sheet-row zn-danger"
1434- onClick = { ( ) => {
1435- const { path : p , title } = noteMenu
1436- setNoteMenu ( null )
1437- trashNote ( p , title )
1438- } }
1439- >
1440- < Icon d = { D . trash } />
1441- Delete
1442- </ button >
1443- </ div >
1444- </ div >
1445- </ div >
1446- </ >
1447- ) }
1448-
14491324 { folderMenu && (
14501325 < >
14511326 < div
0 commit comments