diff --git a/package.json b/package.json index 66829fa..b26ee5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@flyerhq/react-native-firebase-chat-core", - "version": "1.0.0", + "version": "1.0.1", "description": "Actively maintained, community-driven Firebase BaaS for chat applications with an optional chat UI.", "homepage": "https://flyer.chat", "main": "lib/index.js", diff --git a/src/types.ts b/src/types.ts index 3f3a90a..7ffd976 100644 --- a/src/types.ts +++ b/src/types.ts @@ -59,6 +59,7 @@ export interface PreviewDataImage { export interface Room { id: string imageUrl?: string + metadata?: Record name?: string type: 'direct' | 'group' users: User[] diff --git a/src/useRooms.ts b/src/useRooms.ts index 44d23a8..59f8c47 100644 --- a/src/useRooms.ts +++ b/src/useRooms.ts @@ -27,10 +27,12 @@ export const useRooms = () => { const createGroupRoom = async ({ imageUrl, + metadata, name, users, }: { imageUrl?: string + metadata?: Record name: string users: User[] }) => { @@ -44,6 +46,7 @@ export const useRooms = () => { .collection('rooms') .add({ imageUrl, + metadata, name, type: 'group', userIds: roomUsers.map((u) => u.id), @@ -52,13 +55,17 @@ export const useRooms = () => { return { id: room.id, imageUrl, + metadata, name, type: 'group', users: roomUsers, } as Room } - const createRoom = async (otherUser: User) => { + const createRoom = async ( + otherUser: User, + metadata?: Record + ) => { if (!firebaseUser) return const query = await firestore() @@ -89,6 +96,7 @@ export const useRooms = () => { .collection('rooms') .add({ imageUrl: undefined, + metadata, name: undefined, type: 'direct', userIds: users.map((u) => u.id), @@ -96,6 +104,7 @@ export const useRooms = () => { return { id: room.id, + metadata, type: 'direct', users, } as Room diff --git a/src/utils.ts b/src/utils.ts index 5db2e38..c1418f8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -28,6 +28,8 @@ export const processRoomsQuery = async ({ }) => { const promises = query.docs.map(async (doc) => { let imageUrl = (doc.get('imageUrl') as string | null) ?? undefined + let metadata = + (doc.get('metadata') as Record | null) ?? undefined let name = (doc.get('name') as string | null) ?? undefined const type = doc.get('type') as Room['type'] const userIds = doc.get('userIds') as string[] @@ -45,6 +47,7 @@ export const processRoomsQuery = async ({ const room: Room = { id: doc.id, imageUrl, + metadata, name, type, users,