Skip to content

Commit

Permalink
split typescript classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Aug 16, 2024
1 parent c28e3a2 commit ef51434
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 17 deletions.
17 changes: 17 additions & 0 deletions files/js/Hanashi/Faq/Api/Questions/GetSearch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions files/js/Hanashi/Faq/Api/Questions/RenderSearch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions files/js/Hanashi/Faq/BBCode.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@ type Response = {
template: string;
};

export async function renderSearch(): Promise<ApiResult<Response>> {
const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/faq/questions/search/render`);

let response: Response;
try {
response = (await prepareRequest(url).get().fetchAsJson()) as Response;
} catch (e) {
return apiResultFromError(e);
}

return apiResultFromValue(response);
}

export async function searchQuestions(query: string): Promise<ApiResult<Response>> {
const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/faq/questions/search`);
url.searchParams.set("query", query);
Expand Down
19 changes: 19 additions & 0 deletions ts/Hanashi/Faq/Api/Questions/RenderSearch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
import { ApiResult, apiResultFromError, apiResultFromValue } from "WoltLabSuite/Core/Api/Result";

type Response = {
template: string;
};

export async function renderSearch(): Promise<ApiResult<Response>> {
const url = new URL(`${window.WSC_API_URL}index.php?api/rpc/faq/questions/search/render`);

let response: Response;
try {
response = (await prepareRequest(url).get().fetchAsJson()) as Response;
} catch (e) {
return apiResultFromError(e);
}

return apiResultFromValue(response);
}
3 changes: 2 additions & 1 deletion ts/Hanashi/Faq/BBCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { listenToCkeditor } from "WoltLabSuite/Core/Component/Ckeditor/Event";
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
import DomUtil from "WoltLabSuite/Core/Dom/Util";
import * as Language from "WoltLabSuite/Core/Language";
import { renderSearch, searchQuestions } from "./Api/Questions/Search";
import { searchQuestions } from "./Api/Questions/GetSearch";
import { renderSearch } from "./Api/Questions/RenderSearch";

export class FaqBBCode {
private dialog: WoltlabCoreDialogElement;
Expand Down

0 comments on commit ef51434

Please sign in to comment.