mirror of
https://github.com/dralkh/spaceforge.git
synced 2026-07-22 06:45:03 +00:00
fix async method lint errors in review controllers and UI.
This commit is contained in:
parent
77b214b936
commit
a5433e047d
6 changed files with 16 additions and 18 deletions
|
|
@ -58,7 +58,7 @@ export interface IReviewController {
|
|||
*
|
||||
* @param path Path to the postponed note
|
||||
*/
|
||||
handleNotePostponed(path: string): Promise<void>;
|
||||
handleNotePostponed(path: string): void;
|
||||
|
||||
/**
|
||||
* Get the currently loaded notes due for review
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
handleNotePostponed(path: string): void {
|
||||
|
||||
if (this.todayNotes.length === 0) return;
|
||||
|
||||
|
|
|
|||
2
main.ts
2
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<void> {
|
||||
if (this.cssHotReloadIntervalId !== null) {
|
||||
window.clearInterval(this.cssHotReloadIntervalId);
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
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<void> {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
* Simple event emitter implementation
|
||||
*/
|
||||
export type EventMap = Record<string, any[]>;
|
||||
export type EventMap = Record<string, unknown[]>;
|
||||
|
||||
export class EventEmitter<Events extends { [K in keyof Events]: any[] } = Record<string, any[]>> {
|
||||
export class EventEmitter<Events extends { [K in keyof Events]: any[] } = Record<string, unknown[]>> {
|
||||
/**
|
||||
* Event listeners by event name
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue