File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed
apps/web/src/dialogs/settings Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ export const BackupExportSettings: SettingsGroup[] = [
227227 if ( await verifyAccount ( ) )
228228 await exportNotes (
229229 value as "txt" | "md" | "html" | "md-frontmatter" ,
230- db . notes . all
230+ db . notes . exportable
231231 ) ;
232232 }
233233 }
Original file line number Diff line number Diff line change @@ -73,11 +73,21 @@ export async function* exportNotes(
7373 const notePathMap : Map < string , string [ ] > = new Map ( ) ;
7474
7575 for await ( const note of notes
76- . fields ( [ "notes.id" , "notes.title" ] )
76+ . fields ( [ "notes.id" , "notes.title" , "notes.archived" ] )
7777 . iterate ( ) ) {
7878 const filename = `${ sanitizeFilename ( note . title || "Untitled" , {
7979 replacement : "-"
8080 } ) } .${ FORMAT_TO_EXT [ format ] } `;
81+
82+ if ( note . archived ) {
83+ const archivePath = pathTree . add ( "_archive" , "underscore" ) ;
84+ notePathMap . set (
85+ note . id ,
86+ [ archivePath ] . map ( ( p ) => pathTree . add ( join ( p , filename ) ) )
87+ ) ;
88+ continue ;
89+ }
90+
8191 const notebooks = await database . relations
8292 . to ( { id : note . id , type : "note" } , "notebook" )
8393 . get ( ) ;
Original file line number Diff line number Diff line change @@ -251,6 +251,13 @@ export class Notes implements ICollection {
251251 ) ;
252252 }
253253
254+ get exportable ( ) {
255+ return this . collection . createFilter < Note > (
256+ ( qb ) => qb . where ( isFalse ( "dateDeleted" ) ) . where ( isFalse ( "deleted" ) ) ,
257+ this . db . options ?. batchSize
258+ ) ;
259+ }
260+
254261 // isTrashed(id: string) {
255262 // return this.raw.find((item) => item.id === id && isTrashItem(item));
256263 // }
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ function buildFrontmatter(data: TemplateData) {
4040 ] ;
4141 if ( data . pinned ) lines . push ( `pinned: ${ data . pinned } ` ) ;
4242 if ( data . favorite ) lines . push ( `favorite: ${ data . favorite } ` ) ;
43+ if ( data . archived ) lines . push ( `archived: ${ data . archived } ` ) ;
4344 if ( data . color ) lines . push ( `color: ${ data . color } ` ) ;
4445 if ( data . tags ) lines . push ( `tags: ${ data . tags . join ( ", " ) } ` ) ;
4546 return lines . join ( "\n" ) ;
You can’t perform that action at this time.
0 commit comments