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