aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/models/lists.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/trpc/models/lists.ts')
-rw-r--r--packages/trpc/models/lists.ts23
1 files changed, 6 insertions, 17 deletions
diff --git a/packages/trpc/models/lists.ts b/packages/trpc/models/lists.ts
index d278f8d9..4da127d2 100644
--- a/packages/trpc/models/lists.ts
+++ b/packages/trpc/models/lists.ts
@@ -26,7 +26,7 @@ export abstract class List implements PrivacyAware {
private static fromData(
ctx: AuthedContext,
data: ZBookmarkList & { userId: string },
- ): ManualList | SmartList {
+ ) {
if (data.type === "smart") {
return new SmartList(ctx, data);
} else {
@@ -34,21 +34,6 @@ export abstract class List implements PrivacyAware {
}
}
- static async fromName(
- ctx: AuthedContext,
- name: string,
- ): Promise<(ManualList | SmartList)[]> {
- // Names are not unique, so we need to find all lists with the same name
- const lists = await ctx.db.query.bookmarkLists.findMany({
- where: and(
- eq(bookmarkLists.name, name),
- eq(bookmarkLists.userId, ctx.user.id),
- ),
- });
-
- return lists.map((l) => this.fromData(ctx, l));
- }
-
static async fromId(
ctx: AuthedContext,
id: string,
@@ -66,7 +51,11 @@ export abstract class List implements PrivacyAware {
message: "List not found",
});
}
- return this.fromData(ctx, list);
+ if (list.type === "smart") {
+ return new SmartList(ctx, list);
+ } else {
+ return new ManualList(ctx, list);
+ }
}
static async create(