From 807b9ac75cfbfedd1de862bf96ce843d591bf288 Mon Sep 17 00:00:00 2001
From: Ahmad <103906421+ahmadk953@users.noreply.github.com>
Date: Sun, 24 Mar 2024 17:18:00 -0400
Subject: [PATCH] Fixed Liveblocks Config

---
 liveblocks.config.ts | 91 +++++++++++++++++++++++++++++++++++++++++---
 package-lock.json    | 32 ++++------------
 package.json         |  2 +-
 3 files changed, 93 insertions(+), 32 deletions(-)

diff --git a/liveblocks.config.ts b/liveblocks.config.ts
index ea961b7..ba41717 100644
--- a/liveblocks.config.ts
+++ b/liveblocks.config.ts
@@ -1,23 +1,92 @@
-/* import { createClient } from '@liveblocks/client';
+import { createClient } from '@liveblocks/client';
 import { createRoomContext, createLiveblocksContext } from '@liveblocks/react';
 
 const client = createClient({
   publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY!,
+  // authEndpoint: "/api/liveblocks-auth",
   throttle: 16,
+  async resolveUsers({ userIds }) {
+    // Used only for Comments and Notifications. Return a list of user information
+    // retrieved from `userIds`. This info is used in comments, mentions etc.
+
+    // const usersData = await __fetchUsersFromDB__(userIds);
+    //
+    // return usersData.map((userData) => ({
+    //   name: userData.name,
+    //   avatar: userData.avatar.src,
+    // }));
+
+    return [];
+  },
+  async resolveMentionSuggestions({ text }) {
+    // Used only for Comments. Return a list of userIds that match `text`.
+    // These userIds are used to create a mention list when typing in the
+    // composer.
+    //
+    // For example when you type "@jo", `text` will be `"jo"`, and
+    // you should to return an array with John and Joanna's userIds:
+    // ["john@example.com", "joanna@example.com"]
+
+    // const users = await getUsers({ search: text });
+    // return users.map((user) => user.id);
+
+    return [];
+  },
+  async resolveRoomsInfo({ roomIds }) {
+    // Used only for Comments and Notifications. Return a list of room information
+    // retrieved from `roomIds`.
+
+    // const roomsData = await __fetchRoomsFromDB__(roomIds);
+    //
+    // return roomsData.map((roomData) => ({
+    //   name: roomData.name,
+    //   url: roomData.url,
+    // }));
+
+    return [];
+  },
 });
 
+// Presence represents the properties that exist on every user in the Room
+// and that will automatically be kept in sync. Accessible through the
+// `user.presence` property. Must be JSON-serializable.
 type Presence = {
   cursor: { x: number; y: number } | null;
 };
 
-type Storage = {};
+// Optionally, Storage represents the shared document that persists in the
+// Room, even after all users leave. Fields under Storage typically are
+// LiveList, LiveMap, LiveObject instances, for which updates are
+// automatically persisted and synced to all connected clients.
+type Storage = {
+  // author: LiveObject<{ firstName: string, lastName: string }>,
+  // ...
+};
 
-type UserMeta = {};
+// Optionally, UserMeta represents static/readonly metadata on each user, as
+// provided by your own custom auth back end (if used). Useful for data that
+// will not change during a session, like a user's name or avatar.
+type UserMeta = {
+  // id?: string,  // Accessible through `user.id`
+  // info?: Json,  // Accessible through `user.info`
+};
 
-type RoomEvent = {};
+// Optionally, the type of custom events broadcast and listened to in this
+// room. Use a union for multiple events. Must be JSON-serializable.
+type RoomEvent = {
+  // type: "NOTIFICATION",
+  // ...
+};
 
-export type ThreadMetadata = {};
+// Optionally, when using Comments, ThreadMetadata represents metadata on
+// each thread. Can only contain booleans, strings, and numbers.
+export type ThreadMetadata = {
+  // resolved: boolean;
+  // quote: string;
+  // time: number;
+};
 
+// Room-level hooks, use inside `RoomProvider`
 export const {
   suspense: {
     RoomProvider,
@@ -34,6 +103,9 @@ export const {
     useEventListener,
     useErrorListener,
     useStorage,
+    useObject,
+    useMap,
+    useList,
     useBatch,
     useHistory,
     useUndo,
@@ -55,11 +127,16 @@ export const {
     useMarkThreadAsRead,
     useRoomNotificationSettings,
     useUpdateRoomNotificationSettings,
+
+    // These hooks can be exported from either context
+    // useUser,
+    // useRoomInfo
   },
 } = createRoomContext<Presence, Storage, UserMeta, RoomEvent, ThreadMetadata>(
   client
 );
 
+// Project-level hooks, use inside `LiveblocksProvider`
 export const {
   suspense: {
     LiveblocksProvider,
@@ -67,7 +144,9 @@ export const {
     useMarkAllInboxNotificationsAsRead,
     useInboxNotifications,
     useUnreadInboxNotificationsCount,
+
+    // These hooks can be exported from either context
     useUser,
     useRoomInfo,
   },
-} = createLiveblocksContext<UserMeta, ThreadMetadata>(client); */
+} = createLiveblocksContext<UserMeta, ThreadMetadata>(client);
diff --git a/package-lock.json b/package-lock.json
index 89b55ba..3261219 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,7 +13,7 @@
         "@hello-pangea/dnd": "^16.5.0",
         "@liveblocks/client": "^1.11.0",
         "@liveblocks/node": "^1.11.0",
-        "@liveblocks/react": "^1.10.4",
+        "@liveblocks/react": "^1.11.0",
         "@microsoft/eslint-formatter-sarif": "^3.0.0",
         "@prisma/client": "^5.11.0",
         "@prisma/extension-accelerate": "^1.0.0",
@@ -450,16 +450,11 @@
         "@liveblocks/core": "1.11.0"
       }
     },
-    "node_modules/@liveblocks/client/node_modules/@liveblocks/core": {
+    "node_modules/@liveblocks/core": {
       "version": "1.11.0",
       "resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.11.0.tgz",
       "integrity": "sha512-fB5ZlT/HiXHynDiVwtGz7/9ZJy9RF7nziJ7LicVvMc9OCuibLj8xl4Mp/ZHvFSAcbpWA2kKQe0m0wPawSkamIw=="
     },
-    "node_modules/@liveblocks/core": {
-      "version": "1.10.4",
-      "resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.10.4.tgz",
-      "integrity": "sha512-Gh9V3Ayoxhg/GAzVX0LcRo+0BLlaJNkDT8g/Kt7UnXDiXWdi5CXzniqnaPf+9mwrohsVGFdZVdF1ixIzk6JAtA=="
-    },
     "node_modules/@liveblocks/node": {
       "version": "1.11.0",
       "resolved": "https://registry.npmjs.org/@liveblocks/node/-/node-1.11.0.tgz",
@@ -471,18 +466,13 @@
         "node-fetch": "^2.6.1"
       }
     },
-    "node_modules/@liveblocks/node/node_modules/@liveblocks/core": {
-      "version": "1.11.0",
-      "resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.11.0.tgz",
-      "integrity": "sha512-fB5ZlT/HiXHynDiVwtGz7/9ZJy9RF7nziJ7LicVvMc9OCuibLj8xl4Mp/ZHvFSAcbpWA2kKQe0m0wPawSkamIw=="
-    },
     "node_modules/@liveblocks/react": {
-      "version": "1.10.4",
-      "resolved": "https://registry.npmjs.org/@liveblocks/react/-/react-1.10.4.tgz",
-      "integrity": "sha512-HQWbGvMY6Hto3eAOVl/LczNZ17I2YHNzHtSVKqu0a1PuM5joAFI5DgZxvMfBsOUenhdzc0xrF8PaVjF9KB7vUg==",
+      "version": "1.11.0",
+      "resolved": "https://registry.npmjs.org/@liveblocks/react/-/react-1.11.0.tgz",
+      "integrity": "sha512-ADBTXLDR34I2Pj8kvRTpuVkQLAf12Oqk/6zQJ3Qi5L4s9/JBzwUmmH5SqwwtXoxSJtLnIBhQaz62CB5tGrFomQ==",
       "dependencies": {
-        "@liveblocks/client": "1.10.4",
-        "@liveblocks/core": "1.10.4",
+        "@liveblocks/client": "1.11.0",
+        "@liveblocks/core": "1.11.0",
         "nanoid": "^3",
         "use-sync-external-store": "^1.2.0"
       },
@@ -490,14 +480,6 @@
         "react": "^16.14.0 || ^17 || ^18"
       }
     },
-    "node_modules/@liveblocks/react/node_modules/@liveblocks/client": {
-      "version": "1.10.4",
-      "resolved": "https://registry.npmjs.org/@liveblocks/client/-/client-1.10.4.tgz",
-      "integrity": "sha512-klmFd1kVkUbUzYue/tMxRmqJwE/4hw9Yqv5KnbzNAK8HxQ/X6e2m/eEXvNdMsP2Uco0qJDfJsJBjEjKFxCOf1A==",
-      "dependencies": {
-        "@liveblocks/core": "1.10.4"
-      }
-    },
     "node_modules/@microsoft/eslint-formatter-sarif": {
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/@microsoft/eslint-formatter-sarif/-/eslint-formatter-sarif-3.0.0.tgz",
diff --git a/package.json b/package.json
index 8a0132e..60b86f5 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
     "@hello-pangea/dnd": "^16.5.0",
     "@liveblocks/client": "^1.11.0",
     "@liveblocks/node": "^1.11.0",
-    "@liveblocks/react": "^1.10.4",
+    "@liveblocks/react": "^1.11.0",
     "@microsoft/eslint-formatter-sarif": "^3.0.0",
     "@prisma/client": "^5.11.0",
     "@prisma/extension-accelerate": "^1.0.0",