From a5433e047df75fd33642fa5795cffc4266ef648c Mon Sep 17 00:00:00 2001 From: dralkh Date: Thu, 1 Jan 2026 11:36:00 +0300 Subject: [PATCH] fix async method lint errors in review controllers and UI. --- controllers/interfaces.ts | 2 +- controllers/review-controller-core.ts | 4 ++-- main.ts | 2 +- ui/batch-review-modal.ts | 18 ++++++++---------- ui/mcq-modal.ts | 4 ++-- utils/event-emitter.ts | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/controllers/interfaces.ts b/controllers/interfaces.ts index d3407f8..7a1f664 100644 --- a/controllers/interfaces.ts +++ b/controllers/interfaces.ts @@ -58,7 +58,7 @@ export interface IReviewController { * * @param path Path to the postponed note */ - handleNotePostponed(path: string): Promise; + handleNotePostponed(path: string): void; /** * Get the currently loaded notes due for review diff --git a/controllers/review-controller-core.ts b/controllers/review-controller-core.ts index bd1f224..e7a50bc 100644 --- a/controllers/review-controller-core.ts +++ b/controllers/review-controller-core.ts @@ -242,7 +242,7 @@ export class ReviewControllerCore implements IReviewController { await this.plugin.savePluginData(); // Explicitly update navigation state in controller to ensure UI consistency - await this.handleNotePostponed(path); + this.handleNotePostponed(path); // Refresh the sidebar view if available void this.plugin.getSidebarView()?.refresh(); @@ -287,7 +287,7 @@ export class ReviewControllerCore implements IReviewController { * * @param path Path to the postponed note */ - async handleNotePostponed(path: string): Promise { + handleNotePostponed(path: string): void { if (this.todayNotes.length === 0) return; diff --git a/main.ts b/main.ts index fed4086..26f3768 100644 --- a/main.ts +++ b/main.ts @@ -235,7 +235,7 @@ export default class SpaceforgePlugin extends Plugin { window.addEventListener('beforeunload', this.beforeUnloadHandler); } - // eslint-disable-next-line @typescript-eslint/no-misused-promises -- onunload can be async + // @typescript-eslint/no-misused-promises -- onunload can be async async onunload(): Promise { if (this.cssHotReloadIntervalId !== null) { window.clearInterval(this.cssHotReloadIntervalId); diff --git a/ui/batch-review-modal.ts b/ui/batch-review-modal.ts index fda3d4a..35492ff 100644 --- a/ui/batch-review-modal.ts +++ b/ui/batch-review-modal.ts @@ -163,15 +163,13 @@ export class BatchReviewModal extends Modal { this.allMCQSets, (results: Array<{ path: string, success: boolean, response: ReviewResponse, score?: number }>) => { this.results = results; - void (async () => { - await this.recordAllReviews(results); - this.open(); - this.showSummary(); - })(); + this.recordAllReviews(results); + this.open(); + this.showSummary(); } ); consolidatedModal.open(); - } catch (_error) { + } catch { new Notice("Error showing MCQ review. Falling back to manual review."); this.open(); void this.processNextManual(); @@ -183,9 +181,9 @@ export class BatchReviewModal extends Modal { } } - async recordAllReviews(results: Array<{ path: string, success: boolean, response: ReviewResponse, score?: number }>): Promise { + recordAllReviews(results: Array<{ path: string, success: boolean, response: ReviewResponse, score?: number }>): void { for (const result of results) { - await this.plugin.dataStorage.recordReview(result.path, result.response); + this.plugin.dataStorage.recordReview(result.path, result.response); } } @@ -304,11 +302,11 @@ export class BatchReviewModal extends Modal { }); } - async recordManualResult(path: string, response: ReviewResponse): Promise { + recordManualResult(path: string, response: ReviewResponse): void { this.results.push({ path, success: response >= ReviewResponse.CorrectWithDifficulty, response }); // Assuming 3+ is success // Use the data storage method to get the return value - const wasRecorded = await this.plugin.dataStorage.recordReview(path, response); + const wasRecorded = this.plugin.dataStorage.recordReview(path, response); if (!wasRecorded) { // Note was not due, this is just a preview diff --git a/ui/mcq-modal.ts b/ui/mcq-modal.ts index 9688496..aadea4d 100644 --- a/ui/mcq-modal.ts +++ b/ui/mcq-modal.ts @@ -13,14 +13,14 @@ export class MCQModal extends Modal { questionStartTime = 0; isFreshGeneration = false; // Modified callback to include score - private onCompleteCallback: ((path: string, score: number, completed: boolean) => void) | null; + private onCompleteCallback: ((this: void, path: string, score: number, completed: boolean) => void) | null; private selectedAnswerIndex = -1; constructor( plugin: SpaceforgePlugin, notePath: string, mcqSet: MCQSet, - onCompleteCallback: ((path: string, score: number, completed: boolean) => void) | null = null + onCompleteCallback: ((this: void, path: string, score: number, completed: boolean) => void) | null = null ) { super(plugin.app); this.plugin = plugin; diff --git a/utils/event-emitter.ts b/utils/event-emitter.ts index 4a7515a..78ac38b 100644 --- a/utils/event-emitter.ts +++ b/utils/event-emitter.ts @@ -1,9 +1,9 @@ /** * Simple event emitter implementation */ -export type EventMap = Record; +export type EventMap = Record; -export class EventEmitter> { +export class EventEmitter> { /** * Event listeners by event name */