Browse Source

#297

feature/297
みてるぞ 4 days ago
parent
commit
57e82b6ffd
3 changed files with 36 additions and 9 deletions
  1. +2
    -1
      frontend/src/components/PrefetchLink.tsx
  2. +4
    -0
      frontend/src/components/TopNav.tsx
  3. +30
    -8
      frontend/src/pages/theatres/TheatreDetailPage.tsx

+ 2
- 1
frontend/src/components/PrefetchLink.tsx View File

@@ -71,7 +71,8 @@ export default forwardRef<HTMLAnchorElement, Props> (({
|| ev.metaKey || ev.metaKey
|| ev.ctrlKey || ev.ctrlKey
|| ev.shiftKey || ev.shiftKey
|| ev.altKey)
|| ev.altKey
|| (rest.target && rest.target !== '_self'))
return return


ev.preventDefault () ev.preventDefault ()


+ 4
- 0
frontend/src/components/TopNav.tsx View File

@@ -211,6 +211,7 @@ export default (({ user }: Props) => {
<PrefetchLink <PrefetchLink
key={`l-${ i }`} key={`l-${ i }`}
to={item.to} to={item.to}
target={item.to.slice (0, 2) === '//' ? '_blank' : undefined}
className="h-full flex items-center px-3"> className="h-full flex items-center px-3">
{item.name} {item.name}
</PrefetchLink>)))} </PrefetchLink>)))}
@@ -277,6 +278,9 @@ export default (({ user }: Props) => {
<PrefetchLink <PrefetchLink
key={`sp-l-${ i }-${ j }`} key={`sp-l-${ i }-${ j }`}
to={subItem.to} to={subItem.to}
target={subItem.to.slice (0, 2) === '//'
? '_blank'
: undefined}
className="w-full min-h-[36px] flex items-center pl-12"> className="w-full min-h-[36px] flex items-center pl-12">
{subItem.name} {subItem.name}
</PrefetchLink>)))} </PrefetchLink>)))}


+ 30
- 8
frontend/src/pages/theatres/TheatreDetailPage.tsx View File

@@ -23,9 +23,14 @@ import type { NiconicoMetadata,
type TheatreInfo = { type TheatreInfo = {
hostFlg: boolean hostFlg: boolean
postId: number | null postId: number | null
postStartedAt: string | null }
postStartedAt: string | null
watchingUsers: { id: number; name: string }[] }


const INITIAL_THEATRE_INFO = { hostFlg: false, postId: null, postStartedAt: null } as const
const INITIAL_THEATRE_INFO =
{ hostFlg: false,
postId: null,
postStartedAt: null,
watchingUsers: [] as { id: number; name: string }[] } as const




export default (() => { export default (() => {
@@ -93,7 +98,7 @@ export default (() => {
commentsRef.current?.scrollTo ({ commentsRef.current?.scrollTo ({
top: commentsRef.current.scrollHeight, top: commentsRef.current.scrollHeight,
behavior: 'smooth' }) behavior: 'smooth' })
}, [commentsRef])
}, [comments])


useEffect (() => { useEffect (() => {
if (!(id)) if (!(id))
@@ -265,7 +270,7 @@ export default (() => {


<SidebarComponent> <SidebarComponent>
<form <form
className="w-full h-5/6"
className="w-full h-auto border border-black dark:border-white rounded"
onSubmit={async e => { onSubmit={async e => {
e.preventDefault () e.preventDefault ()


@@ -286,25 +291,42 @@ export default (() => {
setSending (false) setSending (false)
} }
}}> }}>
<div className="p-2">
現在の同接数:{theatreInfo.watchingUsers.length}
</div>

<div className="overflow-x-hidden overflow-y-scroll text-wrap w-full h-32
border rounded">
<ul className="list-inside list-disc">
{theatreInfo.watchingUsers.map (user => (
<li key={user.id} className="px-4 py-1 text-sm">
{user.name || `名もなきニジラー(#${ user.id })`}
</li>))}
</ul>
</div>

<div <div
ref={commentsRef} ref={commentsRef}
className="overflow-x-hidden overflow-y-scroll text-wrap
border border-black dark:border-white w-full h-[80vh]">
className="overflow-x-hidden overflow-y-scroll text-wrap w-full
h-[32vh] md:h-[64vh] border rounded">
{comments.map (comment => ( {comments.map (comment => (
<div key={comment.no} className="p-2"> <div key={comment.no} className="p-2">
<div className="w-full"> <div className="w-full">
{comment.content} {comment.content}
</div> </div>
<div className="w-full text-sm text-right"> <div className="w-full text-sm text-right">
by {comment.user ? (comment.user.name || '名もなきニジラー') : '運営'}
by {comment.user
? (comment.user.name || `名もなきニジラー(#${ comment.user.id })`)
: '運営'}
</div> </div>
<div className="w-full text-sm text-right"> <div className="w-full text-sm text-right">
{dateString (comment.createdAt)} {dateString (comment.createdAt)}
</div> </div>
</div>))} </div>))}
</div> </div>

<input <input
className="w-full p-2 border border-black dark:border-white"
className="w-full p-2 border rounded"
type="text" type="text"
value={content} value={content}
onChange={e => setContent (e.target.value)} onChange={e => setContent (e.target.value)}


Loading…
Cancel
Save