Browse Source

ref(ts): Fix types for updateMonitor (#62060)

Evan Purkhiser 1 year ago
parent
commit
d38b99b29c

+ 1 - 1
static/app/actionCreators/monitors.tsx

@@ -49,7 +49,7 @@ export async function updateMonitor(
   orgId: string,
   monitorSlug: string,
   data: Partial<Monitor>
-) {
+): Promise<Monitor | null> {
   addLoadingMessage();
 
   try {

+ 4 - 1
static/app/views/monitors/components/monitorHeaderActions.tsx

@@ -44,7 +44,10 @@ function MonitorHeaderActions({monitor, orgId, onUpdate}: Props) {
 
   const handleUpdate = async (data: Partial<Monitor>) => {
     const resp = await updateMonitor(api, orgId, monitor.slug, data);
-    onUpdate?.(resp);
+
+    if (resp !== null) {
+      onUpdate?.(resp);
+    }
   };
 
   const toggleMute = () => handleUpdate({isMuted: !monitor.isMuted});

+ 4 - 1
static/app/views/monitors/details.tsx

@@ -81,7 +81,10 @@ function MonitorDetails({params, location}: Props) {
       return;
     }
     const resp = await updateMonitor(api, organization.slug, monitor.slug, data);
-    onUpdate(resp);
+
+    if (resp !== null) {
+      onUpdate(resp);
+    }
   };
 
   if (!monitor) {