import { useState } from "react"; import { HubConnectionState } from "@microsoft/signalr"; import { useUser } from "~src/services/user"; import { HttpTimelineInfo } from "~src/http/timeline"; import { getHttpBookmarkClient } from "~src/http/bookmark"; import { pushAlert } from "~src/components/alert"; import { useMobile } from "~src/components/hooks"; import { IconButton } from "~src/components/button"; import { Dialog, FullPageDialog, DialogProvider, useDialog, } from "~src/components/dialog"; import UserAvatar from "~src/components/user/UserAvatar"; import PopupMenu from "~src/components/menu/PopupMenu"; import Card from "~src/components/Card"; import TimelineDeleteDialog from "./TimelineDeleteDialog"; import ConnectionStatusBadge from "./ConnectionStatusBadge"; import TimelineMember from "./TimelineMember"; import TimelinePropertyChangeDialog from "./TimelinePropertyChangeDialog"; import "./TimelineInfoCard.css"; function CollapseButton({ collapse, onClick, className, }: { collapse: boolean; onClick: () => void; className?: string; }) { return ( ); } interface TimelineInfoCardProps { timeline: HttpTimelineInfo; connectionStatus: HubConnectionState; onReload: () => void; } function TimelineInfoContent({ timeline, onReload, }: Omit) { const user = useUser(); const { controller, createDialogSwitch } = useDialog({ member: ( ), property: ( ), delete: , }); return (

{timeline.title} {timeline.nameV2}

{timeline.owner.nickname} @{timeline.owner.username}

{timeline.description}

{user && ( { getHttpBookmarkClient() [timeline.isBookmark ? "delete" : "post"]( user.username, timeline.owner.username, timeline.nameV2, ) .then(onReload, () => { pushAlert({ message: timeline.isBookmark ? "timeline.removeBookmarkFail" : "timeline.addBookmarkFail", color: "danger", }); }); }} /> )} {timeline.manageable && ( )}
); } export default function TimelineInfoCard(props: TimelineInfoCardProps) { const { timeline, connectionStatus, onReload } = props; const [collapse, setCollapse] = useState(true); const isMobile = useMobile((mobile) => { if (!mobile) { switchDialog(null); } else { setCollapse(true); } }); const { controller, switchDialog } = useDialog({ "full-page": ( ), }); return (
{ const open = collapse; setCollapse(!open); if (isMobile && open) { switchDialog("full-page"); } }} />
{!collapse && !isMobile && ( )}
); }