8000 細かいところを色々修正 by keito0tada · Pull Request #21 · comb19/chat_front · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

細かいところを色々修正 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions src/app/channels/[guildID]/[channelID]/page.tsx
8000
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MessageItem from '@/components/message';
import GetAChannel from '@/lib/get_a_channel';
import GetMessages from '@/lib/get_messages';
import { useAuth } from '@clerk/nextjs';
import { FormEventHandler, use, useEffect, useRef, useState } from 'react';
import { use, useEffect, useRef, useState } from 'react';

export default function Page({
params,
Expand All @@ -18,19 +18,26 @@ export default function Page({
undefined,
);
const [messages, setMessages] = useState<Message[]>([]);
const [message, setMessage] = useState<string>('');

const handleSubmit: FormEventHandler<HTMLFormElement> = async (e) => {
console.log('handleSubmit');
e.preventDefault();
const formData = new FormData(e.currentTarget);
console.log(socketRef.current);
const handleEnter = (e: React.KeyboardEvent<HTMLDivElement>) => {
if (e.code == 'Enter' && (e.ctrlKey || e.metaKey)) {
handleSend();
}
};

const handleSend = () => {
if (message.length == 0) {
return;
}
socketRef.current?.send(
JSON.stringify({
action: 'send',
channel_id: channelID,
content: formData.get('message'),
content: message,
}),
);
setMessage('');
};

useEffect(() => {
Expand Down Expand Up @@ -117,23 +124,26 @@ export default function Page({
}, [channelID, getToken]);

return (
<div className="flex-grow flex flex-col">
<div className="flex-grow" >>
<div className="w-full border-b border-b-border h-18 p-1">
<h1 className="text-3xl"># {channel?.name}</h1>
<p>{channel?.description}</p>
</div>
<div className="flex-1 flex flex-col h-full pb-4 px-1">
<ul className="flex-1 h-full">
<div className="pb-4 px-1">
<ul className="h-[calc(100vh-var(--spacing)*38)] overflow-y-scroll">
{messages.map((message: Message) => MessageItem(message))}
</ul>
<form className="flex w-full h-8 bottom-0">
<div className="flex w-full h-10 py-1">
<textarea
name="message"
placeholder="Type your message here"
value={message}
=> setMessage(e.target.value)}
className="flex-grow border border-border resize-none mr-1 px-1"
></textarea>
<input type="submit" value=">" className="w-8 bg-accent" />
</form>
<button className="w-8 bg-accent">
{'>'}
</button>
</div>
</div>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions src/app/channels/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';
import { CreateNewGuildInvitation } from '@/components/guild_invitation';
import GuilList from '@/components/guild_list';
import GuildList from '@/components/guild_list';
import {
SignedIn,
SignedOut,
Expand All @@ -19,7 +19,7 @@ export default function Layout({
const params = useParams();
const [isOpen, setIsOpen] = useState<boolean>(false);
return (
<div className=" h-screen flex flex-col overflow-y-hidden">
<div className="overflow-y-hidden h-screen flex flex-col">
<header className="flex justify-end items-center p-4 gap-4 h-10 border-b-2 border-b-border">
{typeof params.guildID == 'string' && (
<button => setIsOpen(true)}>招待</button>
Expand All @@ -33,7 +33,7 @@ export default function Layout({
</SignedIn>
</header>
<div className="flex-1 flex divide-x-1 divide-border w-screen h-full">
<GuilList />
<GuildList />
{children}
</div>
{typeof params.guildID == 'string' && isOpen && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/guild_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GetGuilds from '@/lib/get_guilds';
import { AddGuildBox, GuildBox } from './guild_box';
import { redirect, useParams } from 'next/navigation';

export default function GuilList() {
export default function GuildList() {
const { getToken } = useAuth();
const [guilds, setGuilds] = useState<ResponseGuild[] | undefined>(undefined);
const params = useParams();
Expand Down
0