🔨 refactor: #102 Remove init logic from query constructor

This commit is contained in:
Nathan Smith 2024-06-29 16:06:55 -04:00
parent c2cc1dea9c
commit f670708c68
2 changed files with 11 additions and 7 deletions

View file

@ -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<void> {
const query = new GithubQuery(el);
await query.init(source);
}

View file

@ -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<void> {
const parsedParams = this.parseCodeblock(source);
if (!parsedParams) {
console.error(`Github Link: simplistic parsing failed`);
} else {
void this.setParams(parsedParams);
await this.setParams(parsedParams);
}
}