@@ -159,40 +159,43 @@ async function openDiscussChannel(channelId, { action, joinCall = false, source
159159    } 
160160} 
161161
162- self . addEventListener ( "notificationclick" ,  ( event )  =>  { 
163-     event . notification . close ( ) ; 
164-     if  ( event . notification . data )  { 
165-         const  {  action,  model,  res_id }  =  event . notification . data ; 
166-         if  ( model  ===  "discuss.channel" )  { 
167-             if  ( event . action  ===  PUSH_NOTIFICATION_ACTION . DECLINE )  { 
168-                 event . waitUntil ( 
169-                     fetch ( "/mail/rtc/channel/leave_call" ,  { 
170-                         headers : {  "Content-type" : "application/json"  } , 
171-                         body : JSON . stringify ( { 
172-                             id : 1 , 
173-                             jsonrpc : "2.0" , 
174-                             method : "call" , 
175-                             params : {  channel_id : res_id  } , 
176-                         } ) , 
177-                         method : "POST" , 
178-                         mode : "cors" , 
179-                         credentials : "include" , 
180-                     } ) 
181-                 ) ; 
182-                 return ; 
183-             } 
162+ async  function  handleNotificationClick ( event )  { 
163+     const  {  action,  model,  res_id }  =  event . notification . data ; 
164+     if  ( model  ===  "discuss.channel" )  { 
165+         if  ( event . action  ===  PUSH_NOTIFICATION_ACTION . DECLINE )  { 
184166            event . waitUntil ( 
185-                 openDiscussChannel ( res_id ,  { 
186-                     action, 
187-                     joinCall : event . action  ===  PUSH_NOTIFICATION_ACTION . ACCEPT , 
167+                 fetch ( "/mail/rtc/channel/leave_call" ,  { 
168+                     headers : {  "Content-type" : "application/json"  } , 
169+                     body : JSON . stringify ( { 
170+                         id : 1 , 
171+                         jsonrpc : "2.0" , 
172+                         method : "call" , 
173+                         params : {  channel_id : res_id  } , 
174+                     } ) , 
175+                     method : "POST" , 
176+                     mode : "cors" , 
177+                     credentials : "include" , 
188178                } ) 
189179            ) ; 
190-         }  else  { 
191-             const  modelPath  =  model . includes ( "." )  ? model  : `m-${ model }  ; 
192-             event . waitUntil ( clients . openWindow ( `/odoo/${ modelPath } ${ res_id }  ) ) ; 
180+             return ; 
193181        } 
182+         return  openDiscussChannel ( res_id ,  { 
183+             action, 
184+             joinCall : event . action  ===  PUSH_NOTIFICATION_ACTION . ACCEPT , 
185+         } ) ; 
186+     }  else  { 
187+         const  modelPath  =  model . includes ( "." )  ? model  : `m-${ model }  ; 
188+         return  clients . openWindow ( `/odoo/${ modelPath } ${ res_id }  ) ; 
189+     } 
190+ } 
191+ 
192+ self . addEventListener ( "notificationclick" ,  async  ( event )  =>  { 
193+     event . notification . close ( ) ; 
194+     if  ( event . notification . data )  { 
195+         event . waitUntil ( handleNotificationClick ( event ) ) ; 
194196    } 
195197} ) ; 
198+ 
196199self . addEventListener ( "push" ,  async  ( event )  =>  { 
197200    const  notification  =  event . data . json ( ) ; 
198201    switch  ( notification . options ?. data ?. type )  { 
0 commit comments