@@ -235,6 +235,33 @@ export default function MainLayout() {
235235 }
236236 } , [ openTabs , activeTabId , notes , setSelectedNote ] ) ;
237237
238+ const handleCloseAllTabs = useCallback ( ( ) => {
239+ // Close all tabs and clear selection
240+ setOpenTabs ( [ ] ) ;
241+ setActiveTabId ( null ) ;
242+ setSelectedNote ( null ) ;
243+ } , [ setSelectedNote ] ) ;
244+
245+ const handleDeleteNote = useCallback ( async ( noteId : string ) => {
246+ // Find and close the tab for this note
247+ const tabToClose = openTabs . find ( t => t . noteId === noteId ) ;
248+ if ( tabToClose ) {
249+ handleTabClose ( tabToClose . id ) ;
250+ }
251+ // Delete the note
252+ await deleteNote ( noteId ) ;
253+ } , [ openTabs , handleTabClose , deleteNote ] ) ;
254+
255+ const handleArchiveNote = useCallback ( async ( noteId : string ) => {
256+ // Find and close the tab for this note
257+ const tabToClose = openTabs . find ( t => t . noteId === noteId ) ;
258+ if ( tabToClose ) {
259+ handleTabClose ( tabToClose . id ) ;
260+ }
261+ // Archive the note
262+ await archiveNote ( noteId ) ;
263+ } , [ openTabs , handleTabClose , archiveNote ] ) ;
264+
238265 const handleDirtyChange = useCallback ( ( isDirty : boolean ) => {
239266 if ( ! selectedNote ) return ;
240267
@@ -356,15 +383,16 @@ export default function MainLayout() {
356383 onCreateCode : handleCreateCode ,
357384 onToggleFolderPanel : handleToggleFolderPanel ,
358385 onEmptyTrash : handleEmptyTrash ,
386+ onRefresh : refetch ,
359387 creatingNote,
360388 } ;
361389
362390 const editorProps : EditorProps = {
363391 note : selectedNote ,
364392 folders,
365393 onUpdateNote : updateNote ,
366- onDeleteNote : deleteNote ,
367- onArchiveNote : archiveNote ,
394+ onDeleteNote : handleDeleteNote ,
395+ onArchiveNote : handleArchiveNote ,
368396 onToggleStar : toggleStar ,
369397 starringStar,
370398 onHideNote : hideNote ,
@@ -437,6 +465,7 @@ export default function MainLayout() {
437465 activeTabId = { activeTabId }
438466 onTabClick = { handleTabClick }
439467 onTabClose = { handleTabClose }
468+ onCloseAll = { handleCloseAllTabs }
440469 />
441470 ) ;
442471}
0 commit comments