-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
272 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
tasks: | ||
- init: npm install && npm run build | ||
command: npm run start | ||
- name: Start development environment | ||
init: npm install | ||
command: npm run dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { StreamPlayerSkeleton } from "@/components/stream-player"; | ||
|
||
const CreatorLoading = () => { | ||
return ( | ||
<div className="h-full"> | ||
<StreamPlayerSkeleton /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreatorLoading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
|
||
const Community = () => { | ||
return ( | ||
<div className="p-6"> | ||
<div className="mb-4"> | ||
<h1 className="text-2xl font-bold">Community Settings</h1> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Community; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
"use client"; | ||
|
||
import React, { useMemo, useState } from "react"; | ||
import { Input } from "../ui/input"; | ||
import { ScrollArea } from "../ui/scroll-area"; | ||
import { useDebounce } from "usehooks-ts"; | ||
import { useParticipants } from "@livekit/components-react"; | ||
import { LocalParticipant, RemoteParticipant } from "livekit-client"; | ||
import { CommunityItem } from "./community-item"; | ||
|
||
interface ChatCommunityProps { | ||
viewerName: string; | ||
hostName: string; | ||
isHidden: boolean; | ||
} | ||
|
||
export const ChatCommunity = ({ | ||
viewerName, | ||
hostName, | ||
isHidden, | ||
}: ChatCommunityProps) => { | ||
const [value, setValue] = useState(""); | ||
const debouncedValue = useDebounce<string>(value, 500); | ||
|
||
const participants = useParticipants(); | ||
|
||
const onChange = (newValue: string) => { | ||
setValue(newValue); | ||
}; | ||
|
||
const filteredParticipants = useMemo(() => { | ||
const deduped = participants.reduce((acc, participant) => { | ||
const hostAsViewer = `host-${participant.identity}`; | ||
if (!acc.some((p) => p.identity === hostAsViewer)) { | ||
acc.push(participant); | ||
} | ||
return acc; | ||
}, [] as (RemoteParticipant | LocalParticipant)[]); | ||
|
||
return deduped.filter((participant) => { | ||
return participant.name | ||
?.toLowerCase() | ||
.includes(debouncedValue.toLowerCase()); | ||
}); | ||
}, [participants, debouncedValue]); | ||
|
||
if (isHidden) { | ||
return ( | ||
<div className="flex flex-1 items-center justify-center"> | ||
<p className="text-sm text-muted-foreground">Community is disabled</p> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="p-4"> | ||
<Input | ||
onChange={(e) => onChange(e.target.value)} | ||
placeholder="Search Community" | ||
className="border-white/10" | ||
/> | ||
<ScrollArea className="gap-y-2 mt-4"> | ||
<p className="text-center text-sm text-muted-foreground hidden last:block p-2"> | ||
No results | ||
</p> | ||
{filteredParticipants.map((participant) => ( | ||
<CommunityItem | ||
key={participant.identity} | ||
hostName={hostName} | ||
viewerName={viewerName} | ||
participantName={participant.name} | ||
participantIdentity={participant.identity} | ||
/> | ||
))} | ||
</ScrollArea> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"use client"; | ||
|
||
import { onBlock } from "@/actions/block"; | ||
import { cn, stringToColor } from "@/lib/utils"; | ||
import { MinusCircle } from "lucide-react"; | ||
import { useTransition } from "react"; | ||
import { toast } from "sonner"; | ||
import { Hint } from "../hint"; | ||
import { Button } from "../ui/button"; | ||
|
||
interface CommunityItemProps { | ||
hostName: string; | ||
viewerName: string; | ||
participantName?: string; | ||
participantIdentity: string; | ||
} | ||
|
||
export const CommunityItem = ({ | ||
hostName, | ||
viewerName, | ||
participantName, | ||
participantIdentity, | ||
}: CommunityItemProps) => { | ||
const [isPending, startTransition] = useTransition(); | ||
|
||
const color = stringToColor(participantName || ""); | ||
const isSelf = participantName === viewerName; | ||
const isHost = viewerName === hostName; | ||
|
||
const handleBlock = () => { | ||
if (!participantName || isSelf || !isHost) return; | ||
|
||
startTransition(() => { | ||
onBlock(participantIdentity) | ||
.then(() => toast.success(`Blocked ${participantName}`)) | ||
.catch(() => toast.error("Something went wrong")); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
"group flex items-center justify-between w-full p-2 rounded-md text-sm hover:bg-white/5", | ||
isPending && "opacity-50 pointer-events-none" | ||
)} | ||
> | ||
<p style={{ color: color }}>{participantName}</p> | ||
{isHost && !isSelf && ( | ||
<Hint label="Block"> | ||
<Button | ||
variant="ghost" | ||
disabled={isPending} | ||
onClick={handleBlock} | ||
className="h-auto w-auto p-1 opacity-0 group-hover:opacity-100 transition" | ||
> | ||
<MinusCircle className="h-4 w-4 text-muted-foreground" /> | ||
</Button> | ||
</Hint> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const ScrollArea = React.forwardRef< | ||
React.ElementRef<typeof ScrollAreaPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> | ||
>(({ className, children, ...props }, ref) => ( | ||
<ScrollAreaPrimitive.Root | ||
ref={ref} | ||
className={cn("relative overflow-hidden", className)} | ||
{...props} | ||
> | ||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]"> | ||
{children} | ||
</ScrollAreaPrimitive.Viewport> | ||
<ScrollBar /> | ||
<ScrollAreaPrimitive.Corner /> | ||
</ScrollAreaPrimitive.Root> | ||
)) | ||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName | ||
|
||
const ScrollBar = React.forwardRef< | ||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>, | ||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> | ||
>(({ className, orientation = "vertical", ...props }, ref) => ( | ||
<ScrollAreaPrimitive.ScrollAreaScrollbar | ||
ref={ref} | ||
orientation={orientation} | ||
className={cn( | ||
"flex touch-none select-none transition-colors", | ||
orientation === "vertical" && | ||
"h-full w-2.5 border-l border-l-transparent p-[1px]", | ||
orientation === "horizontal" && | ||
"h-2.5 flex-col border-t border-t-transparent p-[1px]", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" /> | ||
</ScrollAreaPrimitive.ScrollAreaScrollbar> | ||
)) | ||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName | ||
|
||
export { ScrollArea, ScrollBar } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters