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:
parent
d24fb34075
commit
c2167376bb
@ -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<string>`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)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user