diff --git a/src/components/ShareModal.tsx b/src/components/ShareModal.tsx index e684cfa..f8c0005 100644 --- a/src/components/ShareModal.tsx +++ b/src/components/ShareModal.tsx @@ -20,6 +20,12 @@ export function ShareModal({ video }: Props) { } return { previousValue }; }, + onError: async (err, { videoId }, context) => { + if (context?.previousValue) { + utils.video.get.setData({ videoId }, context.previousValue); + } + console.error(err.message); + }, }); const [linkCopied, setLinkCopied] = useState(false); diff --git a/src/server/api/routers/video.ts b/src/server/api/routers/video.ts index 5d71b46..1946d49 100644 --- a/src/server/api/routers/video.ts +++ b/src/server/api/routers/video.ts @@ -91,6 +91,10 @@ export const videoRouter = createTRPCRouter({ }, }); + if (updateVideo.count === 0) { + throw new TRPCError({ code: "FORBIDDEN" }); + } + return { success: true, updateVideo,