fix(workshop): use PocketBase name

This commit is contained in:
Thomas Camlong authored and ajnart committed 2026-08-13 19:51:44 +02:00
1 parent 63ad879022
commit d2d0d16e4d
18 files changed
+71 -85

No files matched your search

+10 -13
View File
@@ -71,7 +71,7 @@ export interface WorkshopUserRecord extends WorkshopBaseRecord {
email: string;
emailVisibility: boolean;
verified: boolean;
githubUsername: string;
name: string;
isAdmin: boolean;
created: string;
updated: string;
@@ -95,7 +95,7 @@ export interface WorkshopSubmissionRecord extends WorkshopBaseRecord {
export interface WorkshopListingRecord extends Omit<WorkshopSubmissionRecord, "content" | "screenshots"> {
screenshots: string[] | string;
authorGithubUsername: string;
authorName: string;
score: number;
upvotes: number;
downvotes: number;
@@ -167,10 +167,7 @@ function filterListings(items: WorkshopSubmissionSummary[], options: WorkshopLis
if (options.type && options.type !== "all" && item.type !== options.type) return false;
if (options.author && item.author !== options.author) return false;
if (options.includeOutdated === false && item.outdated) return false;
if (
search &&
!`${item.title}\n${item.description}\n${item.authorGithubUsername}`.toLocaleLowerCase().includes(search)
)
if (search && !`${item.title}\n${item.description}\n${item.authorName}`.toLocaleLowerCase().includes(search))
return false;
return true;
}),
@@ -190,7 +187,7 @@ function listingFilter(pocketBase: TypedWorkshopPocketBase, options: WorkshopLis
if (options.type && options.type !== "all") filters.push(pocketBase.filter("type = {:type}", { type: options.type }));
if (options.search?.trim()) {
filters.push(
pocketBase.filter("(title ~ {:search} || description ~ {:search} || authorGithubUsername ~ {:search})", {
pocketBase.filter("(title ~ {:search} || description ~ {:search} || authorName ~ {:search})", {
search: options.search.trim(),
}),
);
@@ -215,7 +212,7 @@ const enrichAuthor = (row: unknown) => {
typeof author === "object" && author !== null && !Array.isArray(author) ? (author as Record<string, unknown>) : {};
return {
...record,
authorGithubUsername: record.authorGithubUsername || user.githubUsername,
authorName: record.authorName || user.name,
};
};
@@ -268,7 +265,7 @@ export class WorkshopBackend {
if (!record) return null;
return workshopUserSchema.parse({
id: record.id,
githubUsername: record.githubUsername || "",
name: record.name || "",
isAdmin: record.isAdmin === true,
});
}
@@ -502,7 +499,7 @@ export class WorkshopBackend {
return items.map((item) =>
workshopReportSchema.parse({
...item,
reporterGithubUsername: item.expand?.reporter?.githubUsername,
reporterName: item.expand?.reporter?.name,
submissionTitle: item.expand?.submission?.title,
}),
);
@@ -539,7 +536,7 @@ export class WorkshopBackend {
return rows.map((row) =>
workshopCommentSchema.parse({
...row,
authorGithubUsername: row.expand?.author?.githubUsername,
authorName: row.expand?.author?.name,
}),
);
} catch (error) {
@@ -554,7 +551,7 @@ export class WorkshopBackend {
.create({ submission, author: this.currentUser?.id ?? "", content: content.trim() }, { expand: "author" });
return workshopCommentSchema.parse({
...row,
authorGithubUsername: row.expand?.author?.githubUsername,
authorName: row.expand?.author?.name,
});
} catch (error) {
throw workshopError(error, "Failed to post comment");
@@ -568,7 +565,7 @@ export class WorkshopBackend {
.update(id, { content: content.trim() }, { expand: "author" });
return workshopCommentSchema.parse({
...row,
authorGithubUsername: row.expand?.author?.githubUsername,
authorName: row.expand?.author?.name,
});
} catch (error) {
throw workshopError(error, "Failed to update comment");
+3 -4
View File
@@ -70,7 +70,7 @@ describe("WorkshopBackend", () => {
token: "token",
record: {
id: "user-id",
githubUsername: "octocat",
name: "octocat",
},
meta: { username: "octocat" },
});
@@ -82,7 +82,7 @@ describe("WorkshopBackend", () => {
expect(mocks.authWithOAuth2.mock.calls[0]?.[0]).not.toHaveProperty("requestKey");
expect(mocks.authWithOAuth2.mock.calls[0]?.[0]).not.toHaveProperty("urlCallback");
expect(mocks.update).not.toHaveBeenCalled();
expect(user).toMatchObject({ githubUsername: "octocat" });
expect(user).toMatchObject({ name: "octocat" });
});
test("exposes the typed submission collection service", () => {
@@ -214,8 +214,7 @@ describe("WorkshopBackend", () => {
1,
12,
expect.objectContaining({
filter:
"(title ~ 'active streams' || description ~ 'active streams' || authorGithubUsername ~ 'active streams')",
filter: "(title ~ 'active streams' || description ~ 'active streams' || authorName ~ 'active streams')",
}),
);
});
+1 -1
View File
@@ -105,7 +105,7 @@ describe("Workshop widget validation", () => {
expect(result.type).toBe("customWidget");
expect(result.screenshots).toEqual([]);
expect(result.authorGithubUsername).toBe("");
expect(result.authorName).toBe("");
expect(result.upvotes).toBe(0);
});
+4 -4
View File
@@ -90,7 +90,7 @@ const workshopFileListSchema = z
export const workshopUserSchema = z.object({
id: z.string(),
githubUsername: z.string().default(""),
name: z.string().default(""),
isAdmin: z.boolean().default(false),
});
export type WorkshopUser = z.infer<typeof workshopUserSchema>;
@@ -113,7 +113,7 @@ const workshopSubmissionBaseObjectSchema = z.object({
widgetSchema: z.string(),
screenshots: workshopFileListSchema,
author: z.string(),
authorGithubUsername: z.string().default(""),
authorName: z.string().default(""),
score: z.number().int().default(0),
upvotes: z.number().int().default(0),
downvotes: z.number().int().default(0),
@@ -173,7 +173,7 @@ export const workshopReportSchema = z.object({
id: z.string(),
submission: z.string(),
reporter: z.string(),
reporterGithubUsername: z.string().default(""),
reporterName: z.string().default(""),
submissionTitle: z.string().default("Deleted submission"),
category: workshopReportCategorySchema,
explanation: z.string(),
@@ -190,7 +190,7 @@ export const workshopCommentSchema = z.object({
content: z.string().min(1).max(2_000),
created: z.string(),
updated: z.string(),
authorGithubUsername: z.string().default(""),
authorName: z.string().default(""),
});
export type WorkshopComment = z.infer<typeof workshopCommentSchema>;