You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
4.8 KiB
1 lines
4.8 KiB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5135],{5135:function(e,n,r){"use strict";r.r(n),r.d(n,{BrowserNotifyModal:function(){return C}});var i=r(47568),t=r(70655),s=r(85893),o=r(84485),a=r(71577),c=r(11382),l=r(25968),u=r(6226),h=r(67294),d=r(4480),f=r(1899);function p(){return(p=(0,i.Z)((function(e,n,r){var i,s,o;return(0,t.__generator)(this,(function(t){switch(t.label){case 0:i="/api/notifications/register",s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:e,destination:n})},t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("".concat(i,"?accessToken=").concat(r),s)];case 2:return t.sent(),[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))).apply(this,arguments)}function w(e){for(var n=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),i=new Uint8Array(r.length),t=0;t<r.length;++t)i[t]=r.charCodeAt(t);return i}function b(e){return v.apply(this,arguments)}function v(){return(v=(0,i.Z)((function(e){var n,r;return(0,t.__generator)(this,(function(i){switch(i.label){case 0:return[4,navigator.serviceWorker.ready];case 1:return[4,(n=i.sent()).pushManager.getSubscription()];case 2:return(r=i.sent())?[3,4]:[4,n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w(e)})];case 3:r=i.sent(),i.label=4;case 4:return[2,JSON.stringify(r)]}}))}))).apply(this,arguments)}var g=r(5225),_=r.n(g);function y(){return"serviceWorker"in navigator&&"PushManager"in window}var x=o.Z.Title,m=function(){return(0,s.jsx)("div",{children:"Browser notifications are not supported in your browser."})},N=function(e){var n=e.start;return(0,s.jsx)("div",{id:"browser-push-preview-box",className:_().pushPreview,children:(0,s.jsxs)("div",{className:_().inner,children:[(0,s.jsxs)("div",{className:_().title,children:[window.location.toString()," wants to"]}),(0,s.jsxs)("div",{className:_().permissionLine,children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{d:"M14 12.3333V13H2V12.3333L3.33333 11V7C3.33333 4.93333 4.68667 3.11333 6.66667 2.52667C6.66667 2.46 6.66667 2.4 6.66667 2.33333C6.66667 1.97971 6.80714 1.64057 7.05719 1.39052C7.30724 1.14048 7.64638 1 8 1C8.35362 1 8.69276 1.14048 8.94281 1.39052C9.19286 1.64057 9.33333 1.97971 9.33333 2.33333C9.33333 2.4 9.33333 2.46 9.33333 2.52667C11.3133 3.11333 12.6667 4.93333 12.6667 7V11L14 12.3333ZM9.33333 13.6667C9.33333 14.0203 9.19286 14.3594 8.94281 14.6095C8.69276 14.8595 8.35362 15 8 15C7.64638 15 7.30724 14.8595 7.05719 14.6095C6.80714 14.3594 6.66667 14.0203 6.66667 13.6667",fill:"#676670"})}),"Show notifications"]}),(0,s.jsxs)("div",{className:_().buttonRow,children:[(0,s.jsx)(a.Z,{type:"primary",className:_().allow,onClick:function(){n()},children:"Allow"}),(0,s.jsx)("button",{type:"button",className:_().disabled,children:"Block"})]})]})})},j=function(){return(0,s.jsxs)("div",{children:[(0,s.jsx)(x,{children:"Notifications are enabled"}),"To disable push notifications from ",window.location.hostname.toString()," access your browser permissions for this site and turn off notifications.",(0,s.jsx)("a",{href:"https://owncast.online/docs/notifications",children:" Learn more."})]})},C=function(){var e=(0,h.useState)(null),n=e[0],r=e[1],o=(0,d.sJ)(f.FI),a=(0,d.sJ)(f.g1),w=(0,h.useState)(!1),v=w[0],g=w[1],_=y()&&"default"!==Notification.permission,C=a.notifications.browser,M=C.publicKey,B=C.enabled&&y();if(_)return(0,s.jsx)(j,{});var S=function(){var e=(0,i.Z)((function(){var e;return(0,t.__generator)(this,(function(n){switch(n.label){case 0:if(y()&&"default"!==Notification.permission)return[2];g(!0),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,b(M)];case 2:return function(e,n,r){p.apply(this,arguments)}("BROWSER_PUSH_NOTIFICATION",n.sent(),o),r(null),[3,4];case 3:return e=n.sent(),r("Error registering for live notifications: ".concat(e.message,". Make sure you're not inside a private browser environment or have previously disabled notifications for this stream.")),[3,4];case 4:return g(!1),[2]}}))}));return function(){return e.apply(this,arguments)}}();return B?(0,s.jsxs)(c.Z,{spinning:v,children:[(0,s.jsxs)(l.Z,{align:"top",children:[(0,s.jsx)(x,{children:"Browser Notifications"}),"Get notified right in the browser each time this stream goes live. Blah blah blah more description text goes here."]}),(0,s.jsx)(l.Z,{children:n}),(0,s.jsx)(l.Z,{align:"top",children:(0,s.jsx)(u.Z,{span:12,children:(0,s.jsx)(N,{start:function(){return S()}})})})]}):(0,s.jsx)(m,{})}},5225:function(e){e.exports={pushPreview:"BrowserNotifyModal_pushPreview__4Og4q",inner:"BrowserNotifyModal_inner__uhFDw",title:"BrowserNotifyModal_title__dd_Lh",permissionLine:"BrowserNotifyModal_permissionLine__K8nyJ",buttonRow:"BrowserNotifyModal_buttonRow__oxJUg",disabled:"BrowserNotifyModal_disabled__v88lb",allow:"BrowserNotifyModal_allow__M9AWC"}}}]); |