From b103b4190cff3e238ef2e69a7d33056507a375b8 Mon Sep 17 00:00:00 2001 From: maciekkoks <85953204+maciekkoks@users.noreply.github.com> Date: Fri, 7 Jul 2023 17:58:34 +0200 Subject: [PATCH] basic changes --- README.md | Bin 2966 -> 2980 bytes src/components/ChatRoom.tsx | 9 +++++---- src/types/collection.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d20b5e9688ee12fb6ee298dd917ad869361ad1f5..f30373c82142f255dfe2fdabe40ab0f0b59bc366 100644 GIT binary patch delta 25 fcmbOxzC?V(Auiqwh7uqwV6bA)XV9N~kn1V{V*3Yu delta 11 TcmZ1?K23bXA+E_6xUK*I9W4bW 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;