File tree 1 file changed +22
-11
lines changed
packages/trpc/server/routers/viewer/availability
1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -27,17 +27,28 @@ export const listHandler = async ({ ctx }: ListOptions) => {
27
27
} ,
28
28
} ) ;
29
29
30
- const defaultScheduleId = await getDefaultScheduleId ( user . id , prisma ) ;
31
-
32
- if ( ! user . defaultScheduleId ) {
33
- await prisma . user . update ( {
34
- where : {
35
- id : user . id ,
36
- } ,
37
- data : {
38
- defaultScheduleId,
39
- } ,
40
- } ) ;
30
+ if ( schedules . length === 0 ) {
31
+ return {
32
+ schedules : [ ] ,
33
+ } ;
34
+ }
35
+
36
+ let defaultScheduleId : number | null ;
37
+ try {
38
+ defaultScheduleId = await getDefaultScheduleId ( user . id , prisma ) ;
39
+
40
+ if ( ! user . defaultScheduleId ) {
41
+ await prisma . user . update ( {
42
+ where : {
43
+ id : user . id ,
44
+ } ,
45
+ data : {
46
+ defaultScheduleId,
47
+ } ,
48
+ } ) ;
49
+ }
50
+ } catch ( error ) {
51
+ defaultScheduleId = null ;
41
52
}
42
53
43
54
return {
You can’t perform that action at this time.
0 commit comments