PageSourceSearch

https://app.us.b2field.com/assets20260427930/NotificationController.js

js b2field.com collected 2026-10-07 22:41:49 UTC 2,395 bytes, 1 lines download raw bytes

1import{u as i,P as c}from"./PushManager.js";import{j as P,a3 as u,q as b,a4 as N,p}from"./index2.js";const M=i.hasNotifications()&&i.isSecureProtocol(),w=i.isNotificationsEnabled()||i.isNotificationsDefault(),r=i.isServiceWorkersEnabled(),l=M&&w,d={PushMessenger:{},NoticesMessenger:{},NoticesChatMessenger:{}},h={PushMessenger:{enabled:!1},NoticesMessenger:{enabled:!0,sound:!1,volume:100,notifications:l&&!r},NoticesChatMessenger:{enabled:!0,sound:!1,volume:100,notifications:l&&!r}},y={loading:!1,browserPushAllowed:r&&!P(),isNotificationsEnabled:l,isStateSaved:Object.keys(d).reduce((e,t)=>e&&!!u(t),!0),settings:b.mapValues(d,(e,t)=>{let s=u(t);return s!==null?s:h[t]})},m={browserPushAllowed:e=>e.browserPushAllowed,isNotificationsEnabled:e=>e.isNotificationsEnabled,settings:e=>e.settings,getStateById:e=>(t,s)=>{let n=e.settings[t];return s&&typeof s=="string"?n[s]:n},isLoading:e=>e.loading,isStateSaved:e=>e.isStateSaved},E={saveState({commit:e},{stateIds:t=[],newVal:s={}}){t=Array.isArray(t)?t:[t],t.forEach(n=>{e("saveState",{stateId:n,newVal:s})})},saveDefaultState({commit:e}){b.each(h,(t,s)=>{e("saveState",{stateId:s,obj:t})})},setLoading({commit:e},t){e("setLoading",t)}},k={saveState(e,{stateId:t,newVal:s}){let n=p(),o={...e.settings[t],...s};N(t,o),n.$set(e.settings,t,o)},setLoading(e,t){e.loading=t},clear(){}},A={namespaced:!0,getters:m,state:y,actions:E,mutations:k};let a=null;function f(){if(i.isNotificationsEnabled()){let e=a.getters["notifications/settings/getStateById"],t=e("PushMessenger");v(),c.applyState(t)}else g()}function g(){let e={enabled:!1};return a.dispatch("notifications/settings/saveState",{stateIds:"PushMessenger",newVal:e}).then(()=>{c.applyState(e)})}function v(){c.on({"state-blocked":()=>S(!0),"state-ready":()=>S(!1),"worker-subscribe-error":g})}function S(e){return a.dispatch("notifications/settings/setLoading",e)}function B(){a.getters["notifications/settings/isStateSaved"]||a.dispatch("notifications/settings/saveDefaultState")}const j={init(e){if(a=e.$store,a.registerModule("notifications/settings",A),B(),i.isServiceWorkersEnabled()){let t=a.getters["notifications/settings/getStateById"],s=t("PushMessenger","enabled");switch(!0){case(s&&i.isNotificationsDefault()):i.notificationsPermissionRequest(f);break;case(!s&&i.isNotificationsDefault()):v();break;case i.isNotificationsEnabled():f();break}}else g()}};export{j as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.