11import { Button } from "@/components/ui/button" ;
2- import { toast } from "sonner" ;
32import { usageDataQueryOptions , videosQueryOptions } from "@/lib/query-utils" ;
3+ import { useDialogsStore } from "@/lib/stores/dialogs" ;
44import { notNanOrDefault } from "@/lib/utils" ;
55import { deleteVideoServerFn } from "@/server-fns/videos" ;
6- import { useDialogsStore } from "@/lib/stores/dialogs" ;
76import { useQueryClient } from "@tanstack/react-query" ;
8- import {
9- Dialog ,
10- DialogContent ,
11- DialogHeader ,
12- DialogTitle ,
13- DialogDescription ,
14- } from "../ui/dialog" ;
7+ import { toast } from "sonner" ;
8+ import { Dialog , DialogContent , DialogDescription , DialogHeader , DialogTitle } from "../ui/dialog" ;
159
1610export function DeleteVideoDialog ( ) {
1711 const queryClient = useQueryClient ( ) ;
1812
19- const closeDeleteVideoDialog = useDialogsStore (
20- ( state ) => state . closeDeleteVideoDialog
21- ) ;
22- const deleteVideoDialogData = useDialogsStore (
23- ( state ) => state . deleteVideoDialogData
24- ) ;
25- const isDeleteVideoDialogOpen = useDialogsStore (
26- ( state ) => state . isDeleteVideoDialogOpen
27- ) ;
13+ const closeDeleteVideoDialog = useDialogsStore ( ( state ) => state . closeDeleteVideoDialog ) ;
14+ const deleteVideoDialogData = useDialogsStore ( ( state ) => state . deleteVideoDialogData ) ;
15+ const isDeleteVideoDialogOpen = useDialogsStore ( ( state ) => state . isDeleteVideoDialogOpen ) ;
2816
2917 async function doDeleteVideo ( ) {
3018 if ( ! isDeleteVideoDialogOpen || ! deleteVideoDialogData ) {
3119 return ;
3220 }
3321
3422 const oldVideos = queryClient . getQueryData ( videosQueryOptions . queryKey ) ;
35- const oldUsageData = queryClient . getQueryData (
36- usageDataQueryOptions . queryKey
37- ) ;
23+ const oldUsageData = queryClient . getQueryData ( usageDataQueryOptions . queryKey ) ;
3824
3925 function reset ( message ?: string ) {
4026 queryClient . setQueryData ( usageDataQueryOptions . queryKey , oldUsageData ) ;
@@ -50,8 +36,7 @@ export function DeleteVideoDialog() {
5036 }
5137
5238 try {
53- const videos =
54- queryClient . getQueryData ( videosQueryOptions . queryKey ) ?. videos ?? [ ] ;
39+ const videos = queryClient . getQueryData ( videosQueryOptions . queryKey ) ?. videos ?? [ ] ;
5540
5641 const video = videos . find ( ( v ) => v . id === deleteVideoDialogData . videoId ) ;
5742
@@ -63,9 +48,8 @@ export function DeleteVideoDialog() {
6348 return {
6449 ...old ,
6550 totalStorageUsed : Math . max (
66- ( old ?. totalStorageUsed ?? 0 ) -
67- notNanOrDefault ( video ?. fileSizeBytes ) ,
68- 0
51+ ( old ?. totalStorageUsed ?? 0 ) - notNanOrDefault ( video ?. fileSizeBytes ) ,
52+ 0 ,
6953 ) ,
7054 } ;
7155 } ) ;
@@ -77,9 +61,7 @@ export function DeleteVideoDialog() {
7761
7862 return {
7963 ...old ,
80- videos : old . videos . filter (
81- ( v ) => v . id !== deleteVideoDialogData . videoId
82- ) ,
64+ videos : old . videos . filter ( ( v ) => v . id !== deleteVideoDialogData . videoId ) ,
8365 } ;
8466 } ) ;
8567
@@ -93,7 +75,7 @@ export function DeleteVideoDialog() {
9375 loading : "Queueing video for deletion..." ,
9476 error : "Error deleting video" ,
9577 success : ( result ) => result . message ,
96- }
78+ } ,
9779 ) ;
9880 } catch ( e ) {
9981 console . error ( e ) ;
@@ -118,8 +100,7 @@ export function DeleteVideoDialog() {
118100 < DialogHeader >
119101 < DialogTitle > Confirm Video Deletion</ DialogTitle >
120102 < DialogDescription >
121- Are you sure you want to delete{ " " }
122- < strong > { deleteVideoDialogData . videoTitle } </ strong > ?
103+ Are you sure you want to delete < strong > { deleteVideoDialogData . videoTitle } </ strong > ?
123104 </ DialogDescription >
124105 </ DialogHeader >
125106 < div className = "flex gap-2 items-end" >
0 commit comments