mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
feat: pancake versioning for comunity themes
This commit is contained in:
1 parent
ccd5c8b1a4
commit
b6728561d1
1 file changed
+35
-9
@@ -314,15 +314,41 @@ export function createCustomThemesHandlers(deps: {
|
|||||||
): boolean {
|
): boolean {
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
const params = new URLSearchParams();
|
const adminThemeParams = (source?: string) => {
|
||||||
params.set("page", String(request.page ?? 1));
|
const params = new URLSearchParams();
|
||||||
params.set("limit", String(Math.min(Number(request.limit ?? 20) || 20, 100)));
|
params.set("page", String(request.page ?? 1));
|
||||||
if (request.status) params.set("status", String(request.status));
|
params.set("limit", String(Math.min(Number(request.limit ?? 20) || 20, 100)));
|
||||||
if (request.source) params.set("source", String(request.source));
|
if (request.status) params.set("status", String(request.status));
|
||||||
const searchRaw = request.search;
|
if (source) params.set("source", source);
|
||||||
const search = typeof searchRaw === "string" ? searchRaw.trim() : "";
|
const search = typeof request.search === "string" ? request.search.trim() : "";
|
||||||
if (search) params.set("search", search);
|
if (search) params.set("search", search);
|
||||||
sendResponse(await customThemesJsonFetch(`/api/bsplus/admin/themes?${params}`, {}, true));
|
return params;
|
||||||
|
};
|
||||||
|
const fetchAdminThemes = (source?: string) =>
|
||||||
|
customThemesJsonFetch(`/api/bsplus/admin/themes?${adminThemeParams(source)}`, {}, true);
|
||||||
|
|
||||||
|
const source =
|
||||||
|
request.source === "community" || request.source === "marketplace"
|
||||||
|
? request.source
|
||||||
|
: undefined;
|
||||||
|
if (source) {
|
||||||
|
sendResponse(await fetchAdminThemes(source));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [community, marketplace] = await Promise.all([
|
||||||
|
fetchAdminThemes("community"),
|
||||||
|
fetchAdminThemes("marketplace"),
|
||||||
|
]);
|
||||||
|
if (community.success === false && marketplace.success === false) {
|
||||||
|
sendResponse(community);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const themes = [
|
||||||
|
...((community.data as { themes?: unknown[] } | undefined)?.themes ?? []),
|
||||||
|
...((marketplace.data as { themes?: unknown[] } | undefined)?.themes ?? []),
|
||||||
|
];
|
||||||
|
sendResponse({ success: true, data: { themes } });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
Reference in new issue
Block a user