From f670708c6839d7071cf6ceb10fdaec9ccc6ceeba Mon Sep 17 00:00:00 2001 From: Nathan Smith Date: Sat, 29 Jun 2024 16:06:55 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor:=20#102=20Remove=20init?= =?UTF-8?q?=20logic=20from=20query=20constructor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/query/processor.ts | 9 +++++++-- src/query/query.ts | 9 ++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/query/processor.ts b/src/query/processor.ts index 7f2c815..dbd1e0e 100644 --- a/src/query/processor.ts +++ b/src/query/processor.ts @@ -1,6 +1,11 @@ import type { MarkdownPostProcessorContext } from "obsidian"; import { GithubQuery } from "./query"; -export function QueryProcessor(source: string, el: HTMLElement, _ctx: MarkdownPostProcessorContext): void { - new GithubQuery(source, el); +export async function QueryProcessor( + source: string, + el: HTMLElement, + _ctx: MarkdownPostProcessorContext, +): Promise { + const query = new GithubQuery(el); + await query.init(source); } diff --git a/src/query/query.ts b/src/query/query.ts index 12bbb58..6489c79 100644 --- a/src/query/query.ts +++ b/src/query/query.ts @@ -142,15 +142,14 @@ export class GithubQuery { private result: TableResult | null = null; private resultMeta: PaginationMeta | null = null; - constructor( - source: string, - private readonly hostElement: HTMLElement, - ) { + constructor(private readonly hostElement: HTMLElement) {} + + public async init(source: string): Promise { const parsedParams = this.parseCodeblock(source); if (!parsedParams) { console.error(`Github Link: simplistic parsing failed`); } else { - void this.setParams(parsedParams); + await this.setParams(parsedParams); } }