From c2167376bbd48ababe474b59077c410b0b97d81f Mon Sep 17 00:00:00 2001 From: Nicholai Date: Sun, 15 Feb 2026 14:33:23 -0700 Subject: [PATCH] Nicholai/fix conversations context (#83) * fix: extract useConversations hook to dedicated context file Move the conversations context and hook from the layout file to src/contexts/conversations-context.tsx. Next.js layouts cannot export hooks or types - only the default component export is allowed. * fix(build): prevent esbuild from bundling memory-provider The memory-provider module imports better-sqlite3, a native Node.js module that cannot run in Cloudflare Workers. This causes OpenNext build failures when esbuild tries to resolve the module. Changes: - Use dynamically constructed import path to prevent static analysis - Remove memory provider from getServerDb (never used on Cloudflare) - Add memory-provider to serverExternalPackages in next.config.ts * fix(lint): rename module variable to loadedModule The variable name 'module' is reserved in Next.js and causes ESLint error @next/next/no-assign-module-variable. * fix(conversations): use drizzle query for organization members --------- Co-authored-by: Nicholai --- src/app/actions/conversations.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/actions/conversations.ts b/src/app/actions/conversations.ts index da90405..a7ec954 100644 --- a/src/app/actions/conversations.ts +++ b/src/app/actions/conversations.ts @@ -11,7 +11,7 @@ import { type NewChannelMember, type NewChannelReadState, } from "@/db/schema-conversations" -import { users } from "@/db/schema" +import { users, organizationMembers } from "@/db/schema" import { getCurrentUser } from "@/lib/auth" import { requirePermission } from "@/lib/permissions" import { revalidatePath } from "next/cache" @@ -170,9 +170,9 @@ export async function createChannel(data: { // get user's organization const orgMember = await db - .select({ organizationId: sql`organization_id` }) - .from(sql`organization_members`) - .where(sql`user_id = ${user.id}`) + .select({ organizationId: organizationMembers.organizationId }) + .from(organizationMembers) + .where(eq(organizationMembers.userId, user.id)) .limit(1) .then((rows) => rows[0] ?? null)