diff --git a/README.md b/README.md index d20b5e9..f30373c 100644 Binary files a/README.md and b/README.md differ diff --git a/src/components/ChatRoom.tsx b/src/components/ChatRoom.tsx index 69cf0ef..f30d3fa 100644 --- a/src/components/ChatRoom.tsx +++ b/src/components/ChatRoom.tsx @@ -1,7 +1,7 @@ import { Session, User } from "@supabase/supabase-js"; import { supabase } from "../lib/supabase-client"; import { useEffect, useState } from "react"; -import { Message } from "../types/collection"; +import { Message, NewMessage } from "../types/collection"; import styled from "styled-components"; import { ChatMessage } from "."; import defaultAvatar from "../assets/defaultAvatar.png"; @@ -62,15 +62,16 @@ export const ChatRoom = ({ session }: ChatRoomProps) => { return; } - const newMessage = { + setIsSending(true); + + const newMessage: NewMessage = { user_name: userName, message_content: messageToSend, user_avatar_url: user.user_metadata.avatar_url || null, user_id: user.id, - provider: user.app_metadata.provider, + provider: user.app_metadata.provider || null, }; - setIsSending(true); const { error } = await supabase.from("Chat").insert([newMessage]); if (error) { diff --git a/src/types/collection.ts b/src/types/collection.ts index 217c39f..17c3b52 100644 --- a/src/types/collection.ts +++ b/src/types/collection.ts @@ -1,3 +1,4 @@ import { Database } from "./supabase"; export type Message = Database["public"]["Tables"]["Chat"]["Row"]; +export type NewMessage = Omit;