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 <nicholaivogelfilms@gmail.com>
This commit is contained in:
Nicholai 2026-02-15 14:33:23 -07:00 committed by GitHub
parent d24fb34075
commit c2167376bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,7 +11,7 @@ import {
type NewChannelMember, type NewChannelMember,
type NewChannelReadState, type NewChannelReadState,
} from "@/db/schema-conversations" } from "@/db/schema-conversations"
import { users } from "@/db/schema" import { users, organizationMembers } from "@/db/schema"
import { getCurrentUser } from "@/lib/auth" import { getCurrentUser } from "@/lib/auth"
import { requirePermission } from "@/lib/permissions" import { requirePermission } from "@/lib/permissions"
import { revalidatePath } from "next/cache" import { revalidatePath } from "next/cache"
@ -170,9 +170,9 @@ export async function createChannel(data: {
// get user's organization // get user's organization
const orgMember = await db const orgMember = await db
.select({ organizationId: sql<string>`organization_id` }) .select({ organizationId: organizationMembers.organizationId })
.from(sql`organization_members`) .from(organizationMembers)
.where(sql`user_id = ${user.id}`) .where(eq(organizationMembers.userId, user.id))
.limit(1) .limit(1)
.then((rows) => rows[0] ?? null) .then((rows) => rows[0] ?? null)