Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
3.0 kB · 110 lines
TSX
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111// React hook wrappers for the pure VOD interaction functions in// @streamplace/core. The hooks pull pdsAgent and userDID from the// streamplace store and call the pure functions.import { createLike as createLikeCore, createVodComment as createVodCommentCore, deleteLike as deleteLikeCore, deleteVodComment as deleteVodCommentCore, getLikeCount as getLikeCountCore, getLikes as getLikesCore, getVodComments as getVodCommentsCore,} from "@streamplace/core";import { useCallback } from "react";import { useDID } from "../streamplace-store";import { usePDSAgent } from "../streamplace-store/xrpc";
export const useCreateVodComment = () => { const pdsAgent = usePDSAgent(); const userDID = useDID(); return useCallback( (params: { text: string; video: string }) => { if (!pdsAgent || !userDID) { throw new Error("No PDS agent or user DID found"); } return createVodCommentCore(pdsAgent, userDID, params); }, [pdsAgent, userDID], );};
export const useDeleteVodComment = () => { const pdsAgent = usePDSAgent(); const userDID = useDID(); return useCallback( (uri: string) => { if (!pdsAgent || !userDID) { throw new Error("No PDS agent or user DID found"); } return deleteVodCommentCore(pdsAgent, userDID, uri); }, [pdsAgent, userDID], );};
export const useCreateLike = () => { const pdsAgent = usePDSAgent(); const userDID = useDID(); return useCallback( (subject: string) => { if (!pdsAgent || !userDID) { throw new Error("No PDS agent or user DID found"); } return createLikeCore(pdsAgent, userDID, subject); }, [pdsAgent, userDID], );};
export const useDeleteLike = () => { const pdsAgent = usePDSAgent(); const userDID = useDID(); return useCallback( (uri: string) => { if (!pdsAgent || !userDID) { throw new Error("No PDS agent or user DID found"); } return deleteLikeCore(pdsAgent, userDID, uri); }, [pdsAgent, userDID], );};
export const useGetVodComments = () => { const pdsAgent = usePDSAgent(); return useCallback( (video: string, limit?: number, cursor?: string) => { if (!pdsAgent) { throw new Error("No PDS agent found"); } return getVodCommentsCore(pdsAgent, video, limit, cursor); }, [pdsAgent], );};
export const useGetLikes = () => { const pdsAgent = usePDSAgent(); return useCallback( (subject: string, limit?: number, cursor?: string) => { if (!pdsAgent) { throw new Error("No PDS agent found"); } return getLikesCore(pdsAgent, subject, limit, cursor); }, [pdsAgent], );};
export const useLikeCount = () => { const pdsAgent = usePDSAgent(); return useCallback( (subject: string) => { if (!pdsAgent) { throw new Error("No PDS agent found"); } return getLikeCountCore(pdsAgent, subject); }, [pdsAgent], );};