-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliveblocks.config.ts
44 lines (34 loc) · 1.03 KB
/
liveblocks.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"use client";
import { createClient } from "@liveblocks/client";
import { createRoomContext } from "@liveblocks/react";
export const client = createClient({
authEndpoint: "/api/liveblocks-auth",
});
const {
suspense: { RoomProvider, useThreads },
} = createRoomContext(client, {
// Get users' info from their ID
resolveUsers: async ({ userIds }) => {
const searchParams = new URLSearchParams(
userIds.map((userId) => ["userIds", userId])
);
try {
const response = await fetch(`/api/users?${searchParams}`);
return response.json();
} catch (error) {
console.error(123, error);
}
},
// Find a list of users that match the current search term
resolveMentionSuggestions: async ({ text }) => {
const searchParams = new URLSearchParams({ text });
try {
const response = await fetch(`/api/users/search?${searchParams}`);
return response.json();
} catch (error) {
console.error(456, error);
return [];
}
},
});
export { RoomProvider, useThreads };