fix: Fixed the issue where imported notes would have incorrect "Created" date and time
This commit is contained in:
@@ -7,7 +7,7 @@ import { GoogleKeepConverter } from './GoogleKeepConverter/GoogleKeepConverter'
|
|||||||
import { PlaintextConverter } from './PlaintextConverter/PlaintextConverter'
|
import { PlaintextConverter } from './PlaintextConverter/PlaintextConverter'
|
||||||
import { SimplenoteConverter } from './SimplenoteConverter/SimplenoteConverter'
|
import { SimplenoteConverter } from './SimplenoteConverter/SimplenoteConverter'
|
||||||
import { readFileAsText } from './Utils'
|
import { readFileAsText } from './Utils'
|
||||||
import { DecryptedTransferPayload } from '@standardnotes/models'
|
import { DecryptedTransferPayload, NoteContent } from '@standardnotes/models'
|
||||||
|
|
||||||
export type NoteImportType = 'plaintext' | 'evernote' | 'google-keep' | 'simplenote' | 'aegis'
|
export type NoteImportType = 'plaintext' | 'evernote' | 'google-keep' | 'simplenote' | 'aegis'
|
||||||
|
|
||||||
@@ -81,9 +81,23 @@ export class Importer {
|
|||||||
async importFromTransferPayloads(payloads: DecryptedTransferPayload[]) {
|
async importFromTransferPayloads(payloads: DecryptedTransferPayload[]) {
|
||||||
const insertedItems = await Promise.all(
|
const insertedItems = await Promise.all(
|
||||||
payloads.map(async (payload) => {
|
payloads.map(async (payload) => {
|
||||||
const itemPayload = this.application.items.createPayloadFromObject(payload)
|
const content = payload.content as NoteContent
|
||||||
const item = this.application.items.createItemFromPayload(itemPayload)
|
const note = this.application.mutator.createTemplateItem(
|
||||||
return this.application.mutator.insertItem(item)
|
payload.content_type,
|
||||||
|
{
|
||||||
|
text: content.text,
|
||||||
|
title: content.title,
|
||||||
|
noteType: content.noteType,
|
||||||
|
editorIdentifier: content.editorIdentifier,
|
||||||
|
references: content.references,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
created_at: payload.created_at,
|
||||||
|
updated_at: payload.updated_at,
|
||||||
|
uuid: payload.uuid,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return this.application.mutator.insertItem(note)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
return insertedItems
|
return insertedItems
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class ImportModalController {
|
|||||||
files: ImportModalFile[] = []
|
files: ImportModalFile[] = []
|
||||||
importTag: SNTag | undefined = undefined
|
importTag: SNTag | undefined = undefined
|
||||||
|
|
||||||
constructor(application: WebApplication, private navigationController: NavigationController) {
|
constructor(private application: WebApplication, private navigationController: NavigationController) {
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
isVisible: observable,
|
isVisible: observable,
|
||||||
setIsVisible: action,
|
setIsVisible: action,
|
||||||
@@ -149,26 +149,18 @@ export class ImportModalController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const currentDate = new Date()
|
const currentDate = new Date()
|
||||||
const importTagPayload: DecryptedTransferPayload<TagContent> = {
|
const importTagItem = this.application.mutator.createTemplateItem<TagContent, SNTag>(ContentType.Tag, {
|
||||||
uuid: UuidGenerator.GenerateUuid(),
|
title: `Imported on ${currentDate.toLocaleString()}`,
|
||||||
created_at: currentDate,
|
expanded: false,
|
||||||
created_at_timestamp: currentDate.getTime(),
|
iconString: '',
|
||||||
updated_at: currentDate,
|
references: importedPayloads
|
||||||
updated_at_timestamp: currentDate.getTime(),
|
.filter((payload) => payload.content_type === ContentType.Note)
|
||||||
content_type: ContentType.Tag,
|
.map((payload) => ({
|
||||||
content: {
|
content_type: ContentType.Note,
|
||||||
title: `Imported on ${currentDate.toLocaleString()}`,
|
uuid: payload.uuid,
|
||||||
expanded: false,
|
})),
|
||||||
iconString: '',
|
})
|
||||||
references: importedPayloads
|
const importTag = await this.application.mutator.insertItem(importTagItem)
|
||||||
.filter((payload) => payload.content_type === ContentType.Note)
|
|
||||||
.map((payload) => ({
|
|
||||||
content_type: ContentType.Note,
|
|
||||||
uuid: payload.uuid,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const [importTag] = await this.importer.importFromTransferPayloads([importTagPayload])
|
|
||||||
if (importTag) {
|
if (importTag) {
|
||||||
this.setImportTag(importTag as SNTag)
|
this.setImportTag(importTag as SNTag)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user