Skip to content

Commit

Permalink
basic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekt07 committed Jul 7, 2023
1 parent 176f02b commit b103b41
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Binary file modified README.md
Binary file not shown.
9 changes: 5 additions & 4 deletions src/components/ChatRoom.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/types/collection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Database } from "./supabase";

export type Message = Database["public"]["Tables"]["Chat"]["Row"];
export type NewMessage = Omit<Message, "id" | "created_at" | "deleted">;

0 comments on commit b103b41

Please sign in to comment.