"use client"; import { useShareNoteByLocalId, useUserInfoById, } from "@/app/post/[id]/request"; import { Content_Public_Storage_Key, Default_Debounce_Duration, } from "@/lib/consts"; import { Session } from "next-auth"; import { useEffect, useState } from "react"; import { Editor as InkeEditor } from "inkejs"; import { JSONContent } from "@tiptap/react"; import UINotFound from "../../../ui/layout/not-found"; import { LoadingCircle } from "@/ui/shared/icons"; import NewPostButton from "@/ui/new-post-button"; import Image from "next/image"; import { BadgeInfo } from "lucide-react"; import Tooltip from "@/ui/shared/tooltip"; import { fetcher, timeAgo } from "@/lib/utils"; import { ContentItem } from "@/lib/types/note"; export default function Wrapper({ id, session, }: { id: string; session: Session | null; }) { const { share, isLoading } = useShareNoteByLocalId(id); const [canRenderGuide, setCanRenderGuide] = useState(false); const [parseContent, setParseContent] = useState(); const [currentContent, setCurrentContent] = useState({}); const { user } = useUserInfoById(share?.data.userId); useEffect(() => { if (window) { localStorage.removeItem(Content_Public_Storage_Key); } }, []); useEffect(() => { if (share && share.data && share.data.data) { const parsed = JSON.parse(share.data.data || "{}"); setParseContent(parsed); setCurrentContent(parsed.content); setCanRenderGuide(true); const title = parsed.title || "Untitled"; document.title = `${title} | Inke`; } }, [share]); const handleUpdateKeeps = async () => { if (share && share.data) { await fetcher("/api/share/update/keep", { method: "POST", body: JSON.stringify({ id: share.data.id }), }); } }; return (
{isLoading && } {!isLoading && share && share.data && canRenderGuide && ( <> {user && (
avatar
{user.name}

{share.data.click}  clicks,  {share.data.keeps} keeps {parseContent.created_at && ( Updated {timeAgo(parseContent.updated_at)} )}

What's keep writing?

Keep writing allows you to quickly create a note with the same content as this note locally.

} fullWidth={false} >
)} )} {!isLoading && !share.data && } ); }