Skip to content

Commit 9450351

Browse files
committed
Merge remote-tracking branch 'origin/6.2' into 6.3
# Conflicts: # ts/WoltLabSuite/Core/Controller/Moderation/Activation.ts # ts/WoltLabSuite/Core/Controller/Moderation/Report.ts # wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Moderation/Activation.js # wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Moderation/Report.js
2 parents c6dfdc4 + e992eaa commit 9450351

File tree

57 files changed

+306
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+306
-425
lines changed

ts/WoltLabSuite/Core/Acp/Controller/ExceptionLog/View.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ import { wheneverFirstSeen } from "WoltLabSuite/Core/Helper/Selector";
1515
import { getPhrase } from "WoltLabSuite/Core/Language";
1616

1717
async function showDialog(button: HTMLElement): Promise<void> {
18-
const response = await renderException(button.closest("tr")!.dataset.objectId!);
19-
if (!response.ok) {
20-
return;
21-
}
18+
const { template } = await renderException(button.closest("tr")!.dataset.objectId!);
2219

23-
const dialog = dialogFactory().fromHtml(response.value.template).withoutControls();
20+
const dialog = dialogFactory().fromHtml(template).withoutControls();
2421
dialog.content.querySelector(".jsCopyButton")?.addEventListener("click", () => {
2522
void copyTextToClipboard(dialog.content.querySelector<HTMLTextAreaElement>(".jsCopyException")!.value);
2623
});

ts/WoltLabSuite/Core/Acp/Controller/VersionTracker/VersionList.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ function initRevertButtons(container: HTMLElement, objectType: string, objectId:
1919
return;
2020
}
2121

22-
const response = await revertVersion(objectType, objectId, parseInt(button.dataset.objectId!));
23-
if (response.ok) {
24-
showDefaultSuccessSnackbar().addEventListener("snackbar:close", () => {
25-
window.location.reload();
26-
});
27-
}
22+
await revertVersion(objectType, objectId, parseInt(button.dataset.objectId!));
23+
24+
showDefaultSuccessSnackbar().addEventListener("snackbar:close", () => {
25+
window.location.reload();
26+
});
2827
});
2928
});
3029
}

ts/WoltLabSuite/Core/Api/Articles/GetArticlePopover.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "WoltLabSuite/Core/Api/Result";
11+
import { fromInfallibleApiRequest } from "WoltLabSuite/Core/Api/Result";
1212

1313
type Response = {
1414
template: string;
1515
};
1616

17-
export async function getArticlePopover(articleId: number): Promise<ApiResult<string>> {
17+
export async function getArticlePopover(articleId: number): Promise<string> {
1818
const url = new URL(`${window.WSC_RPC_API_URL}core/articles/${articleId}/popover`);
1919

20-
let response: Response;
21-
try {
22-
response = (await prepareRequest(url).get().fetchAsJson()) as Response;
23-
} catch (e) {
24-
return apiResultFromError(e);
25-
}
26-
27-
return apiResultFromValue(response.template);
20+
return fromInfallibleApiRequest(() => {
21+
return prepareRequest(url).get().fetchAsJson();
22+
});
2823
}

ts/WoltLabSuite/Core/Api/Cronjobs/Logs/ClearLogs.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
*/
1010

1111
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
12-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result";
12+
import { fromInfallibleApiRequest } from "../../Result";
1313

14-
export async function clearLogs(): Promise<ApiResult<[]>> {
15-
try {
16-
await prepareRequest(`${window.WSC_RPC_API_URL}core/cronjobs/logs`).delete().fetchAsJson();
17-
} catch (e) {
18-
return apiResultFromError(e);
19-
}
20-
21-
return apiResultFromValue([]);
14+
export async function clearLogs(): Promise<[]> {
15+
return fromInfallibleApiRequest(() => {
16+
return prepareRequest(`${window.WSC_RPC_API_URL}core/cronjobs/logs`).delete().fetchAsJson();
17+
});
2218
}

ts/WoltLabSuite/Core/Api/Exceptions/RenderException.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
11+
import { fromInfallibleApiRequest } from "../Result";
1212

1313
type Response = {
1414
template: string;
1515
};
1616

17-
export async function renderException(exceptionId: string): Promise<ApiResult<Response>> {
17+
export async function renderException(exceptionId: string): Promise<Response> {
1818
const url = new URL(`${window.WSC_RPC_API_URL}core/exceptions/${exceptionId}/render`);
1919

20-
let response: Response;
21-
try {
22-
response = (await prepareRequest(url).get().fetchAsJson()) as Response;
23-
} catch (e) {
24-
return apiResultFromError(e);
25-
}
26-
27-
return apiResultFromValue(response);
20+
return fromInfallibleApiRequest(() => {
21+
return prepareRequest(url).get().fetchAsJson();
22+
});
2823
}

ts/WoltLabSuite/Core/Api/Gridviews/GetRow.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
11+
import { fromInfallibleApiRequest } from "../Result";
1212

1313
type Response = {
1414
template: string;
@@ -18,7 +18,7 @@ export async function getRow(
1818
gridViewClass: string,
1919
objectId: string | number,
2020
gridViewParameters?: Map<string, string>,
21-
): Promise<ApiResult<Response>> {
21+
): Promise<Response> {
2222
const url = new URL(`${window.WSC_RPC_API_URL}core/grid-views/row`);
2323
url.searchParams.set("gridView", gridViewClass);
2424
url.searchParams.set("objectID", objectId.toString());
@@ -34,12 +34,7 @@ export async function getRow(
3434
});
3535
}
3636

37-
let response: Response;
38-
try {
39-
response = (await prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson()) as Response;
40-
} catch (e) {
41-
return apiResultFromError(e);
42-
}
43-
44-
return apiResultFromValue(response);
37+
return fromInfallibleApiRequest(() => {
38+
return prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson();
39+
});
4540
}

ts/WoltLabSuite/Core/Api/Gridviews/GetRows.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
11+
import { fromInfallibleApiRequest } from "../Result";
1212

1313
type Response = {
1414
template: string;
@@ -24,7 +24,7 @@ export async function getRows(
2424
sortOrder: string = "ASC",
2525
filters?: Map<string, string>,
2626
gridViewParameters?: Map<string, string>,
27-
): Promise<ApiResult<Response>> {
27+
): Promise<Response> {
2828
const url = new URL(`${window.WSC_RPC_API_URL}core/grid-views/rows`);
2929
url.searchParams.set("gridView", gridViewClass);
3030
url.searchParams.set("pageNo", pageNo.toString());
@@ -47,12 +47,7 @@ export async function getRows(
4747
});
4848
}
4949

50-
let response: Response;
51-
try {
52-
response = (await prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson()) as Response;
53-
} catch (e) {
54-
return apiResultFromError(e);
55-
}
56-
57-
return apiResultFromValue(response);
50+
return fromInfallibleApiRequest(() => {
51+
return prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson();
52+
});
5853
}

ts/WoltLabSuite/Core/Api/Interactions/GetBulkContextMenuOptions.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,17 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
11+
import { fromInfallibleApiRequest } from "../Result";
1212

1313
type Response = {
1414
template: string;
1515
};
1616

17-
export async function getBulkContextMenuOptions(
18-
providerClassName: string,
19-
objectIds: number[],
20-
): Promise<ApiResult<Response>> {
21-
let response: Response;
22-
try {
23-
response = (await prepareRequest(`${window.WSC_RPC_API_URL}core/interactions/bulk-context-menu-options`)
17+
export async function getBulkContextMenuOptions(providerClassName: string, objectIds: number[]): Promise<Response> {
18+
return fromInfallibleApiRequest(() => {
19+
return prepareRequest(`${window.WSC_RPC_API_URL}core/interactions/bulk-context-menu-options`)
2420
.post({ provider: providerClassName, objectIDs: objectIds })
2521
.disableLoadingIndicator()
26-
.fetchAsJson()) as Response;
27-
} catch (e) {
28-
return apiResultFromError(e);
29-
}
30-
31-
return apiResultFromValue(response);
22+
.fetchAsJson();
23+
});
3224
}

ts/WoltLabSuite/Core/Api/Interactions/GetContextMenuOptions.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,18 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
11+
import { fromInfallibleApiRequest } from "../Result";
1212

1313
type Response = {
1414
template: string;
1515
};
1616

17-
export async function getContextMenuOptions(
18-
providerClassName: string,
19-
objectId: number | string,
20-
): Promise<ApiResult<Response>> {
17+
export async function getContextMenuOptions(providerClassName: string, objectId: number | string): Promise<Response> {
2118
const url = new URL(`${window.WSC_RPC_API_URL}core/interactions/context-menu-options`);
2219
url.searchParams.set("provider", providerClassName);
2320
url.searchParams.set("objectID", objectId.toString());
2421

25-
let response: Response;
26-
try {
27-
response = (await prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson()) as Response;
28-
} catch (e) {
29-
return apiResultFromError(e);
30-
}
31-
32-
return apiResultFromValue(response);
22+
return fromInfallibleApiRequest(() => {
23+
return prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson();
24+
});
3325
}

ts/WoltLabSuite/Core/Api/ListViews/GetItem.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend";
11-
import { ApiResult, apiResultFromError, apiResultFromValue } from "../Result";
11+
import { fromInfallibleApiRequest } from "../Result";
1212

1313
type Response = {
1414
template: string;
@@ -18,7 +18,7 @@ export async function getItem(
1818
listViewClass: string,
1919
objectId: string | number,
2020
listViewParameters?: Map<string, string>,
21-
): Promise<ApiResult<Response>> {
21+
): Promise<Response> {
2222
const url = new URL(`${window.WSC_RPC_API_URL}core/list-views/item`);
2323
url.searchParams.set("listView", listViewClass);
2424
url.searchParams.set("objectID", objectId.toString());
@@ -34,12 +34,7 @@ export async function getItem(
3434
});
3535
}
3636

37-
let response: Response;
38-
try {
39-
response = (await prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson()) as Response;
40-
} catch (e) {
41-
return apiResultFromError(e);
42-
}
43-
44-
return apiResultFromValue(response);
37+
return fromInfallibleApiRequest(() => {
38+
return prepareRequest(url).get().allowCaching().disableLoadingIndicator().fetchAsJson();
39+
});
4540
}

0 commit comments

Comments
 (0)