chore: legacy fixes (#2343)

This commit is contained in:
Mo
2023-07-03 08:03:25 -05:00
committed by GitHub
parent 6d5cbcb396
commit d79e7b14b1
14 changed files with 148 additions and 95 deletions

View File

@@ -62,12 +62,12 @@ describe('LinkingController', () => {
alerts: {} as jest.Mocked<WebApplication['alerts']>,
sync: {} as jest.Mocked<WebApplication['sync']>,
mutator: {} as jest.Mocked<WebApplication['mutator']>,
itemControllerGroup: {} as jest.Mocked<WebApplication['itemControllerGroup']>,
} as unknown as jest.Mocked<WebApplication>
application.getPreference = jest.fn()
application.addSingleEventObserver = jest.fn()
application.streamItems = jest.fn()
application.itemControllerGroup = {} as jest.Mocked<WebApplication['itemControllerGroup']>
application.sync.sync = jest.fn()
Object.defineProperty(application, 'items', { value: {} as jest.Mocked<ItemManagerInterface> })

View File

@@ -197,11 +197,13 @@ export class LinkingController extends AbstractViewController {
const linkNoteAndFile = async (note: SNNote, file: FileItem) => {
const updatedFile = await this.application.mutator.associateFileWithNote(file, note)
if (updatedFile && featureTrunkVaultsEnabled()) {
const noteVault = this.application.vaults.getItemVault(note)
const fileVault = this.application.vaults.getItemVault(updatedFile)
if (noteVault && !fileVault) {
await this.application.vaults.moveItemToVault(noteVault, file)
if (featureTrunkVaultsEnabled()) {
if (updatedFile) {
const noteVault = this.application.vaults.getItemVault(note)
const fileVault = this.application.vaults.getItemVault(updatedFile)
if (noteVault && !fileVault) {
await this.application.vaults.moveItemToVault(noteVault, file)
}
}
}
}