From a8a4807fa107ae63eb93f85b8ee256c63e45ea56 Mon Sep 17 00:00:00 2001 From: Diivvuu Date: Thu, 17 Oct 2024 05:15:39 +0530 Subject: [PATCH] leftovers cleared --- convex/channels.ts | 12 +++++- convex/workspaces.ts | 41 ++++++++++++++++--- .../member/[memberId]/conversation.tsx | 7 +++- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/convex/channels.ts b/convex/channels.ts index 8aaea87..7a52876 100644 --- a/convex/channels.ts +++ b/convex/channels.ts @@ -24,7 +24,17 @@ export const remove = mutation({ throw new Error("Unauthorized"); } - // const [messagess] + const [messages] = await Promise.all([ + ctx.db + .query("messages") + .withIndex("by_channel_id", (q) => q.eq("channelId", args.id)) + .collect(), + ]); + + for (const message of messages) { + await ctx.db.delete(message._id); + } + await ctx.db.delete(args.id); return args.id; diff --git a/convex/workspaces.ts b/convex/workspaces.ts index 6611bd4..44b5f1a 100644 --- a/convex/workspaces.ts +++ b/convex/workspaces.ts @@ -226,16 +226,45 @@ export const remove = mutation({ throw new Error("Unauthorized"); } - const [members] = await Promise.all([ - ctx.db - .query("members") - .withIndex("by_workspace_id", (q) => q.eq("workspaceId", args.id)) - .collect(), - ]); + const [members, channels, conversations, messages, reactions] = + await Promise.all([ + ctx.db + .query("members") + .withIndex("by_workspace_id", (q) => q.eq("workspaceId", args.id)) + .collect(), + ctx.db + .query("channels") + .withIndex("by_workspace_id", (q) => q.eq("workspaceId", args.id)) + .collect(), + ctx.db + .query("conversations") + .withIndex("by_workspace_id", (q) => q.eq("workspaceId", args.id)) + .collect(), + ctx.db + .query("messages") + .withIndex("by_workspace_id", (q) => q.eq("workspaceId", args.id)) + .collect(), + ctx.db + .query("reactions") + .withIndex("by_workspace_id", (q) => q.eq("workspaceId", args.id)) + .collect(), + ]); for (const member of members) { await ctx.db.delete(member._id); } + for (const channel of channels) { + await ctx.db.delete(channel._id); + } + for (const conversation of conversations) { + await ctx.db.delete(conversation._id); + } + for (const message of messages) { + await ctx.db.delete(message._id); + } + for (const reaction of reactions) { + await ctx.db.delete(reaction._id); + } await ctx.db.delete(args.id); diff --git a/src/app/workspace/[workspaceId]/member/[memberId]/conversation.tsx b/src/app/workspace/[workspaceId]/member/[memberId]/conversation.tsx index ff23820..b4ee19e 100644 --- a/src/app/workspace/[workspaceId]/member/[memberId]/conversation.tsx +++ b/src/app/workspace/[workspaceId]/member/[memberId]/conversation.tsx @@ -6,6 +6,7 @@ import { Loader } from "lucide-react"; import { Header } from "./header"; import { ChatInput } from "./chat-input"; import { MessageList } from "@/components/message-list"; +import { usePanel } from "@/hooks/use-panel"; interface ConversationProps { id: Id<"conversations">; @@ -14,6 +15,8 @@ interface ConversationProps { export const Conversations = ({ id }: ConversationProps) => { const memberId = useMemberId(); + const { onOpenProfile, onClose } = usePanel(); + const { data: member, isLoading: memberLoading } = useGetMember({ id: memberId, }); @@ -34,7 +37,9 @@ export const Conversations = ({ id }: ConversationProps) => {
{}} + onClick={() => { + onOpenProfile(memberId); + }} />