mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
1 line
4.4 KiB
JavaScript
Vendored
1 line
4.4 KiB
JavaScript
Vendored
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1398],{41398:function(e,i,s){"use strict";s.r(i),s.d(i,{BrowserNotifyModal:function(){return v}});var t=s(85893),o=s(85818),n=s(71577),r=s(11382),a=s(71230),l=s(67294),c=s(4480),d=s(37068),h=s(44974);async function f(e,i,s){console.log("saveNotificationRegistration");let t={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:e,destination:i})};await fetch("".concat("/api/notifications/register","?accessToken=").concat(s),t)}async function w(e){let i=await navigator.serviceWorker.ready,s=await i.pushManager.getSubscription();return s||(s=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(e){let i="=".repeat((4-e.length%4)%4),s=(e+i).replace(/-/g,"+").replace(/_/g,"/"),t=window.atob(s),o=new Uint8Array(t.length);for(let e=0;e<t.length;++e)o[e]=t.charCodeAt(e);return o}(e)})),JSON.stringify(s)}var u=s(67940),p=s.n(u),b=s(34148),m=s(69183);let{Title:x}=o.Z,_=()=>(0,t.jsx)("div",{children:"Browser notifications are not supported in your browser."}),g=()=>(0,t.jsx)("div",{children:"Browser notifications are not supported for local servers."}),y=e=>{let{start:i}=e;return(0,t.jsx)("div",{id:"browser-push-preview-box",className:p().pushPreview,children:(0,t.jsxs)("div",{className:p().inner,children:[(0,t.jsxs)("div",{className:p().title,children:[window.location.toString()," wants to"]}),(0,t.jsxs)("div",{className:p().permissionLine,children:[(0,t.jsx)("svg",{className:p().bell,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.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,t.jsx)("span",{className:p().showNotificationsText,children:"Show notifications"})]}),(0,t.jsxs)("div",{className:p().buttonRow,children:[(0,t.jsx)(n.Z,{type:"primary",onClick:()=>{i()},children:"Allow"}),(0,t.jsx)("button",{type:"button",className:p().disabled,children:"Block"})]})]})})},N=()=>(0,t.jsxs)("div",{children:[(0,t.jsx)(x,{level:2,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,t.jsx)("a",{href:"https://owncast.online/docs/notifications",children:" Learn more."})]}),v=()=>{let[e,i]=(0,l.useState)(null),s=(0,c.sJ)(h.FI),o=(0,c.sJ)(h.g1),[n,u]=(0,l.useState)(!1),x=(0,b.Z)()&&"default"!==Notification.permission,{notifications:v}=o,{browser:j}=v,{publicKey:C}=j,M=j.enabled&&(0,b.Z)();if(x)return(0,t.jsx)(N,{});let B=async()=>{if(!(0,b.Z)()||"default"===Notification.permission){u(!0);try{let e=await w(C);f("BROWSER_PUSH_NOTIFICATION",e,s),i(null)}catch(e){i("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."))}u(!1)}};return"localhost"===window.location.hostname?(0,t.jsx)(g,{}):M?(0,t.jsx)(d.SV,{fallbackRender:e=>{let{error:i,resetErrorBoundary:s}=e;return(0,t.jsx)(m.A,{componentName:"BrowserNotifyModal",message:i.message,retryFunction:s})},children:(0,t.jsxs)(r.Z,{spinning:n,children:[(0,t.jsxs)(a.Z,{className:p().description,children:["Get notified right in the browser each time this stream goes live.",(0,t.jsx)("a",{href:"https://owncast.online/docs/notifications/#browser-notifications",children:"Learn more"}),"\xa0 about Owncast browser notifications."]}),(0,t.jsx)(a.Z,{children:e}),(0,t.jsx)(y,{start:()=>B()})]})}):(0,t.jsx)(_,{})}},67940: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"}}}]); |