fix: harden workshop availability
This commit is contained in:
28 files changed
+671
-279
No files matched your search
@@ -497,6 +497,9 @@ export const integrationDefs = {
|
||||
|
||||
export const integrationKinds = objectKeys(integrationDefs) as AtLeastOneOf<IntegrationKind>;
|
||||
|
||||
export const isIntegrationKind = (integration: string): integration is IntegrationKind =>
|
||||
Object.hasOwn(integrationDefs, integration);
|
||||
|
||||
export const getIconUrl = (integration: IntegrationKind) => integrationDefs[integration].iconUrl;
|
||||
|
||||
export const getIntegrationName = (integration: IntegrationKind) => integrationDefs[integration].name;
|
||||
|
||||
@@ -896,6 +896,10 @@
|
||||
"search": "Search integrations",
|
||||
"noResults": {
|
||||
"title": "There are no integrations yet"
|
||||
},
|
||||
"outdated": {
|
||||
"title": "Some integrations need a database update",
|
||||
"description": "{count} outdated integrations were hidden to keep this page available. Restart Homarr to apply pending data migrations."
|
||||
}
|
||||
},
|
||||
"create": {
|
||||
@@ -4484,8 +4488,18 @@
|
||||
"title": "No creations found",
|
||||
"description": "Adjust the filters or check back after the community has shared more."
|
||||
},
|
||||
"offline": {
|
||||
"title": "Workshop is offline",
|
||||
"description": "You can keep using Homarr. Reconnect to browse or install community creations.",
|
||||
"unavailableDescription": "Homarr could not reach Workshop. The rest of your instance is still available.",
|
||||
"cachedTitle": "Showing saved Workshop results",
|
||||
"cachedDescription": "These results were saved on this device. Some details and actions may be unavailable until Workshop reconnects.",
|
||||
"actionUnavailable": "Reconnect before installing or applying this creation."
|
||||
},
|
||||
"error": {
|
||||
"loadTitle": "Workshop could not load",
|
||||
"detailTitle": "This creation is unavailable",
|
||||
"detailDescription": "Its source is not saved on this device and Workshop could not be reached.",
|
||||
"publish": "The creation could not be published",
|
||||
"install": "The creation could not be used",
|
||||
"wrongType": "This creation does not match the requested type"
|
||||
@@ -5716,6 +5730,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"workshop": {
|
||||
"label": "Workshop"
|
||||
},
|
||||
"users": {
|
||||
"label": "Users",
|
||||
"create": {
|
||||
|
||||
@@ -37,6 +37,7 @@ export interface WorkshopListOptions {
|
||||
sort?: "top" | "newest";
|
||||
search?: string;
|
||||
author?: string;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
export interface WorkshopPage<T> {
|
||||
@@ -71,6 +72,9 @@ const asWorkshopError = (error: unknown, fallback: string) => {
|
||||
const code = parsedCode.success ? parsedCode.data : errorCodeForStatus(error.status);
|
||||
return new WorkshopError(code, message, error.status);
|
||||
}
|
||||
if (error instanceof TypeError) {
|
||||
return new WorkshopError("unavailable", fallback);
|
||||
}
|
||||
return new WorkshopError("unknown", error instanceof Error ? error.message : fallback);
|
||||
};
|
||||
|
||||
@@ -146,6 +150,7 @@ export class WorkshopClient {
|
||||
.getList(options.page ?? 1, options.perPage ?? 24, {
|
||||
filter: filters.join(" && "),
|
||||
sort: options.sort === "newest" ? "-created" : "-score,-created",
|
||||
signal: options.signal,
|
||||
});
|
||||
return { ...result, items: result.items.map((item) => workshopSubmissionSummarySchema.parse(item)) };
|
||||
} catch (error) {
|
||||
@@ -153,9 +158,11 @@ export class WorkshopClient {
|
||||
}
|
||||
}
|
||||
|
||||
async get(id: string): Promise<WorkshopSubmissionDetail> {
|
||||
async get(id: string, signal?: AbortSignal): Promise<WorkshopSubmissionDetail> {
|
||||
try {
|
||||
return workshopSubmissionDetailSchema.parse(await this.pocketBase.collection("submissions").getOne(id));
|
||||
return workshopSubmissionDetailSchema.parse(
|
||||
await this.pocketBase.collection("submissions").getOne(id, { signal }),
|
||||
);
|
||||
} catch (error) {
|
||||
throw asWorkshopError(error, "Submission not found");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user