File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import {
1919 readFileTypeFromBuffer ,
2020} from '../../lib/electronOnly'
2121import { join } from 'path'
22- import { NoteDocEditibleProps } from '../../lib/db/types'
22+ import { NoteDocImportableProps } from '../../lib/db/types'
2323import { isFolderPathnameValid } from '../../lib/db/utils'
2424import { useDb } from '../../lib/db'
2525import { JsonObject } from 'type-fest'
@@ -112,6 +112,8 @@ const ImportLegacyNotesForm = ({ storageId }: ImportLegacyNotesFormProps) => {
112112 const title = normalizeString ( note . title )
113113 const tags = normalizeTags ( note . tags )
114114 const data = { }
115+ const createdAt = normalizeString ( note . createdAt )
116+ const updatedAt = normalizeString ( note . updatedAt )
115117 switch ( note . type ) {
116118 case 'MARKDOWN_NOTE' : {
117119 const legacyNoteId = noteFileName . replace ( / .c s o n $ / , '' )
@@ -164,12 +166,14 @@ const ImportLegacyNotesForm = ({ storageId }: ImportLegacyNotesFormProps) => {
164166 )
165167 }
166168
167- const noteProps : NoteDocEditibleProps = {
169+ const noteProps : NoteDocImportableProps = {
168170 folderPathname,
169171 title,
170172 content,
171173 tags,
172174 data,
175+ createdAt,
176+ updatedAt,
173177 }
174178 return noteProps
175179 }
@@ -186,12 +190,14 @@ const ImportLegacyNotesForm = ({ storageId }: ImportLegacyNotesFormProps) => {
186190 . map ( stringifySnippet )
187191 . join ( '\n\n' ) } `
188192
189- const noteProps : NoteDocEditibleProps = {
193+ const noteProps : NoteDocImportableProps = {
190194 folderPathname,
191195 title,
192196 content,
193197 tags,
194198 data,
199+ createdAt,
200+ updatedAt,
195201 }
196202 return noteProps
197203 }
Original file line number Diff line number Diff line change 77 Attachment ,
88 FolderDocEditibleProps ,
99 NoteDocEditibleProps ,
10+ NoteDocImportableProps ,
1011 TagDocEditibleProps ,
1112 TagDoc ,
1213 PopulatedFolderDoc ,
@@ -257,7 +258,7 @@ class FSNoteDb implements NoteDb {
257258 await unlinkFile ( attachmentPathname )
258259 }
259260
260- async createNote ( noteProps : Partial < NoteDocEditibleProps > ) {
261+ async createNote ( noteProps : Partial < NoteDocEditibleProps | NoteDocImportableProps > ) {
261262 const now = getNow ( )
262263 const noteDoc : NoteDoc = {
263264 _id : generateNoteId ( ) ,
@@ -266,9 +267,9 @@ class FSNoteDb implements NoteDb {
266267 tags : [ ] ,
267268 folderPathname : '/' ,
268269 data : { } ,
269- ...noteProps ,
270270 createdAt : now ,
271271 updatedAt : now ,
272+ ...noteProps ,
272273 trashed : false ,
273274 _rev : generateId ( ) ,
274275 }
Original file line number Diff line number Diff line change 44 ObjectMap ,
55 NoteDoc ,
66 NoteDocEditibleProps ,
7+ NoteDocImportableProps ,
78 PopulatedFolderDoc ,
89 PopulatedTagDoc ,
910 Attachment ,
@@ -262,7 +263,7 @@ export function createDbStoreCreator(
262263 [ setStorageMap , syncStorage ]
263264 )
264265 const createNote = useCallback (
265- async ( storageId : string , noteProps : Partial < NoteDocEditibleProps > ) => {
266+ async ( storageId : string , noteProps : Partial < NoteDocEditibleProps | NoteDocImportableProps > ) => {
266267 const storage = storageMap [ storageId ]
267268 if ( storage == null ) {
268269 return
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ export type NoteDocEditibleProps = {
4343 data : JsonObject
4444}
4545
46+ export type NoteDocImportableProps = {
47+ createdAt : string
48+ updatedAt : string
49+ } & NoteDocEditibleProps
50+
4651export type NoteDoc = {
4752 _id : string
4853 createdAt : string
You can’t perform that action at this time.
0 commit comments