import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import{useCallback as t}from"react";import{selectTemplateOnDeletion as o,removeTemplateFromList as n,setBusy as s}from"../utils.js";import{Action as i}from"../../types.js";import{useGet as a}from"./sharedHooks.js";import{useCloseTemplateMenu as m}from"./useCloseTemplateMenu.js";import{unshareAppSettingsTemplate as p}from"../../../../clients/jsonApi/index.js";import"../../../../utils/index.js";import{showSuccessNotification as c}from"../../../../utils/notificationToasts.js";var u=function(u){var f=a("get"),l=a("set"),d=m();return t(e(r.mark((function e(){var t,a,m,b;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d(),t=f(),a=t.currentTemplateId,!(m=n(f,l,u))){e.next=18;break}return b=s(l,m.id,i.Delete),e.prev=5,e.next=8,p(f().appKey,m.id,[f().userId]);case 8:if(a!==m.id){e.next=11;break}return e.next=11,o(f,l);case 11:c('Following has been disabled for "'.concat(m.name,'".')),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(5),console.error(e.t0);case 17:b();case 18:case"end":return e.stop()}}),e,null,[[5,14]])}))),[d,f,l,u])};export{u as useUnfollowTemplate};
//# sourceMappingURL=useUnfollowTemplate.js.map
