Files
standardnotes-app-web/packages/snjs/lib/Migrations/Versions/2_7_0.ts
Karol Sójko 325737bfbd chore: fix ContentType usage (#2353)
* chore: fix ContentType usage

* chore: fix specs
2023-07-12 13:53:29 +02:00

33 lines
1.1 KiB
TypeScript

import { CompoundPredicate, Predicate, SNComponent } from '@standardnotes/models'
import { Migration } from '@Lib/Migrations/Migration'
import { ApplicationStage } from '@standardnotes/services'
import { ContentType } from '@standardnotes/domain-core'
export class Migration2_7_0 extends Migration {
static override version(): string {
return '2.7.0'
}
protected registerStageHandlers(): void {
this.registerStageHandler(ApplicationStage.FullSyncCompleted_13, async () => {
await this.deleteBatchManagerSingleton()
this.markDone()
})
}
private async deleteBatchManagerSingleton() {
const batchMgrId = 'org.standardnotes.batch-manager'
const batchMgrPred = new CompoundPredicate('and', [
new Predicate<SNComponent>('content_type', '=', ContentType.TYPES.Component),
new Predicate<SNComponent>('identifier', '=', batchMgrId),
])
const batchMgrSingleton = this.services.singletonManager.findSingleton(ContentType.TYPES.Component, batchMgrPred)
if (batchMgrSingleton) {
await this.services.mutator.setItemToBeDeleted(batchMgrSingleton)
}
}
}