diff --git a/README.md b/README.md
index 0ee9392..236300d 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,15 @@
+
+## 📈 GitHub Repository Stats
+| 🌟 **Stars** | 🍴 **Forks** | 🐛 **Issues** | 🔔 **Open PRs** | 🔕 **Closed PRs** | 🛠️ **Languages** | ✅ **Contributors** |
+|--------------|--------------|---------------|-----------------|------------------|------------------|------------------|
+| ![GitHub stars](https://img.shields.io/github/stars/MitulSonagara/truth-tunnel) | ![forks](https://img.shields.io/github/forks/MitulSonagara/truth-tunnel) | ![issues](https://img.shields.io/github/issues/MitulSonagara/truth-tunnel?color=32CD32) | ![pull requests](https://img.shields.io/github/issues-pr/MitulSonagara/truth-tunnel?color=FFFF8F) | ![Closed PRs](https://img.shields.io/github/issues-pr-closed/MitulSonagara/truth-tunnel?color=20B2AA) | ![Languages](https://img.shields.io/github/languages/count/MitulSonagara/truth-tunnel?color=20B2AA) | ![Contributors](https://img.shields.io/github/contributors/MitulSonagara/truth-tunnel?color=00FA9A) |
+
+
+
+
### This project is now OFFICIALLY accepted for
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 243a8c2..d571efc 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -32,7 +32,7 @@ model EncryptionKey {
publicKey String @unique
userId String @unique @db.ObjectId
testEncryption String @default("unsecured")
- user User @relation(fields: [userId], references: [id])
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Message {
@@ -41,7 +41,7 @@ model Message {
userId String @db.ObjectId
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
- User User @relation(fields: [userId], references: [id])
+ User User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Account {
diff --git a/src/app/(app)/dashboard/page.tsx b/src/app/(app)/dashboard/page.tsx
index 4dc94b8..a9a6ee3 100644
--- a/src/app/(app)/dashboard/page.tsx
+++ b/src/app/(app)/dashboard/page.tsx
@@ -3,14 +3,22 @@ import { acceptMessageSchema } from "@/schemas/acceptMessageSchema";
import { zodResolver } from "@hookform/resolvers/zod";
import { toast } from "sonner";
import { useSession } from "next-auth/react";
-import React from "react";
+import React, { useEffect } from "react";
import { useForm } from "react-hook-form";
import { User } from "next-auth";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import Navbar from "@/components/Navbar";
import { Separator } from "@/components/ui/separator";
-import { Copy, ListX, Loader2, RefreshCcw, Search } from "lucide-react";
+import {
+ Edit3,
+ GlobeLockIcon,
+ ListX,
+ Loader2,
+ RefreshCcw,
+ Search,
+ Copy,
+} from "lucide-react";
import { Input } from "@/components/ui/input";
import { useDeleteModal } from "@/stores/modals-store";
import GenerateEncryptionAlert from "@/components/alerts/generate-encryption-alert";
@@ -25,13 +33,43 @@ import Messages from "@/components/Messages";
import { useCheckEncryptionKey } from "@/hooks/check-encryptionkey";
import { useProfileUrl } from "@/hooks/useProfileUrl";
+import checkAndSaveKeys from "@/helpers/checkAndSaveKeys";
+
import { useSearchSheet } from "@/stores/sheets-store";
const Page = () => {
const hasEncryptionKey = useCheckEncryptionKey();
const deleteMessagesModal = useDeleteModal();
- const { data: session, status } = useSession();
+ const { data: session, status, update } = useSession();
+
+ useEffect(() => {
+ const generateKeysIfNeeded = async () => {
+ if (!hasEncryptionKey) {
+ try {
+ // checks and generates key and save in IndexDB
+ const success = await checkAndSaveKeys();
+ if (success) {
+ await update({
+ type: "change_key",
+ key: true,
+ });
+ window.location.reload();
+ } else {
+ toast.error("Error", {
+ description: "Failed to auto generate keys",
+ });
+ }
+ } catch (error) {
+ toast.error("Error", {
+ description: "An unexpected error occurred while generating keys",
+ });
+ }
+ }
+ };
+
+ generateKeysIfNeeded();
+ }, [hasEncryptionKey, update]);
const queryClient = useQueryClient();
const searchSheet = useSearchSheet();
@@ -110,8 +148,8 @@ const Page = () => {
<>