chore: show toast when duplicating note and update last modified date for duplicated note (#2379)
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { AlertService, InternalEventBusInterface } from '@standardnotes/services'
|
||||
import { MutatorService, PayloadManager, ItemManager } from '../'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
import { UuidGenerator, sleep } from '@standardnotes/utils'
|
||||
|
||||
const setupRandomUuid = () => {
|
||||
UuidGenerator.SetGenerator(() => String(Math.random()))
|
||||
@@ -65,6 +65,14 @@ describe('mutator service', () => {
|
||||
|
||||
expect(note.userModifiedDate).toEqual(pinnedNote?.userModifiedDate)
|
||||
})
|
||||
|
||||
it('should update the modification date of duplicated notes', async () => {
|
||||
const note = await insertNote('hello')
|
||||
await sleep(1, false, 'Delaying duplication by 1ms to create unique timestamps')
|
||||
const duplicatedNote = await mutatorService.duplicateItem(note)
|
||||
|
||||
expect(duplicatedNote.userModifiedDate.getTime()).toBeGreaterThan(note.userModifiedDate.getTime())
|
||||
})
|
||||
})
|
||||
|
||||
describe('linking', () => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
import { TagsToFoldersMigrationApplicator } from '@Lib/Migrations/Applicators/TagsToFolders'
|
||||
import {
|
||||
ActionsExtensionMutator,
|
||||
AppDataField,
|
||||
ComponentInterface,
|
||||
ComponentMutator,
|
||||
CreateDecryptedMutatorForItem,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
DecryptedItemMutator,
|
||||
DecryptedPayload,
|
||||
DecryptedPayloadInterface,
|
||||
DefaultAppDomain,
|
||||
DeleteItemMutator,
|
||||
EncryptedItemInterface,
|
||||
FeatureRepoMutator,
|
||||
@@ -319,7 +321,14 @@ export class MutatorService extends AbstractService implements MutatorClientInte
|
||||
payload,
|
||||
baseCollection: this.payloadManager.getMasterCollection(),
|
||||
isConflict,
|
||||
additionalContent,
|
||||
additionalContent: {
|
||||
appData: {
|
||||
[DefaultAppDomain]: {
|
||||
[AppDataField.UserModifiedDate]: new Date(),
|
||||
},
|
||||
},
|
||||
...additionalContent,
|
||||
},
|
||||
})
|
||||
|
||||
await this.payloadManager.emitPayloads(resultingPayloads, PayloadEmitSource.LocalChanged)
|
||||
|
||||
Reference in New Issue
Block a user