2 lines
4.1 KiB
JavaScript
2 lines
4.1 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1424],{11424:function(e,i,t){"use strict";t.r(i),t.d(i,{BrowserNotifyModal:function(){return x}});var s=t(85893),o=t(84485),n=t(71577),r=t(11382),a=t(71230),l=t(67294),c=t(4480),d=t(77466);async function h(e,i,t){let s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:e,destination:i})};try{await fetch("".concat("/api/notifications/register","?accessToken=").concat(t),s)}catch(o){console.error(o)}}async function w(e){let i=await navigator.serviceWorker.ready,t=await i.pushManager.getSubscription();return t||(t=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let i="=".repeat((4-e.length%4)%4),t=(e+i).replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(t),o=new Uint8Array(s.length);for(let n=0;n<s.length;++n)o[n]=s.charCodeAt(n);return o}(e)})),JSON.stringify(t)}var f=t(38851),u=t.n(f),p=t(83469);let{Title:b}=o.Z,_=()=>(0,s.jsx)("div",{children:"Browser notifications are not supported in your browser."}),y=e=>{let{start:i}=e;return(0,s.jsx)("div",{id:"browser-push-preview-box",className:u().pushPreview,children:(0,s.jsxs)("div",{className:u().inner,children:[(0,s.jsxs)("div",{className:u().title,children:[window.location.toString()," wants to"]}),(0,s.jsxs)("div",{className:u().permissionLine,children:[(0,s.jsx)("svg",{className:u().bell,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"})}),(0,s.jsx)("span",{className:u().showNotificationsText,children:"Show notifications"})]}),(0,s.jsxs)("div",{className:u().buttonRow,children:[(0,s.jsx)(n.Z,{type:"primary",onClick:()=>{i()},children:"Allow"}),(0,s.jsx)("button",{type:"button",className:u().disabled,children:"Block"})]})]})})},m=()=>(0,s.jsxs)("div",{children:[(0,s.jsx)(b,{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."})]}),x=()=>{let[e,i]=(0,l.useState)(null),t=(0,c.sJ)(d.FI),o=(0,c.sJ)(d.g1),[n,f]=(0,l.useState)(!1),b=(0,p.Z)()&&"default"!==Notification.permission,{notifications:x}=o,{browser:N}=x,{publicKey:g}=N,v=N.enabled&&(0,p.Z)();if(b)return(0,s.jsx)(m,{});let j=async()=>{if(!(0,p.Z)()||"default"===Notification.permission){f(!0);try{let e=await w(g);h("BROWSER_PUSH_NOTIFICATION",e,t),i(null)}catch(s){i("Error registering for live notifications: ".concat(s.message,". Make sure you're not inside a private browser environment or have previously disabled notifications for this stream."))}f(!1)}};return v?(0,s.jsxs)(r.Z,{spinning:n,children:[(0,s.jsxs)(a.Z,{className:u().description,children:["Get notified right in the browser each time this stream goes live.",(0,s.jsx)("a",{href:"https://owncast.online/docs/notifications/#browser-notifications",children:"Learn more"}),"\xa0 about Owncast browser notifications."]}),(0,s.jsx)(a.Z,{children:e}),(0,s.jsx)(y,{start:()=>j()})]}):(0,s.jsx)(_,{})}},38851:function(e){e.exports={description:"BrowserNotifyModal_description__tMKKq",pushPreview:"BrowserNotifyModal_pushPreview__4Og4q",inner:"BrowserNotifyModal_inner__uhFDw",title:"BrowserNotifyModal_title__dd_Lh",permissionLine:"BrowserNotifyModal_permissionLine__K8nyJ",bell:"BrowserNotifyModal_bell__9mIeI",buttonRow:"BrowserNotifyModal_buttonRow__oxJUg",disabled:"BrowserNotifyModal_disabled__v88lb"}}}]);
|
|
//# sourceMappingURL=1424.438542aebf6af653.js.map
|