refactor: fix noteviewcontroller de-init
This commit is contained in:
@@ -38,7 +38,7 @@ export class NoteViewController implements ItemViewControllerInterface {
|
|||||||
private saveTimeout?: ReturnType<typeof setTimeout>
|
private saveTimeout?: ReturnType<typeof setTimeout>
|
||||||
private defaultTagUuid: UuidString | undefined
|
private defaultTagUuid: UuidString | undefined
|
||||||
private defaultTag?: SNTag
|
private defaultTag?: SNTag
|
||||||
private savingLocallyPromise = Deferred<void>()
|
private savingLocallyPromise: ReturnType<typeof Deferred<void>> | null = null
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private application: WebApplication,
|
private application: WebApplication,
|
||||||
@@ -59,6 +59,11 @@ export class NoteViewController implements ItemViewControllerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit(): void {
|
deinit(): void {
|
||||||
|
if (!this.savingLocallyPromise) {
|
||||||
|
this.performDeinitSafely()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
void this.savingLocallyPromise.promise.then(() => {
|
void this.savingLocallyPromise.promise.then(() => {
|
||||||
this.performDeinitSafely()
|
this.performDeinitSafely()
|
||||||
})
|
})
|
||||||
@@ -212,7 +217,9 @@ export class NoteViewController implements ItemViewControllerInterface {
|
|||||||
void this.undebouncedSave({
|
void this.undebouncedSave({
|
||||||
...params,
|
...params,
|
||||||
onLocalPropagationComplete: () => {
|
onLocalPropagationComplete: () => {
|
||||||
this.savingLocallyPromise.resolve()
|
if (this.savingLocallyPromise) {
|
||||||
|
this.savingLocallyPromise.resolve()
|
||||||
|
}
|
||||||
resolve()
|
resolve()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user