PageSourceSearch

https://reporting.happy-or-not.com/assets/NotificationSettings-BqQUsEvY.js

js happy-or-not.com collected 2026-10-02 03:14:51 UTC 7,815 bytes, 41 lines download raw bytes

1import{ac as H,j as t,r,P as ni,aa as ai}from"./main-CX5PqK3X.js";import{cX as w,iS as E,cz as ci,iT as ri,iU as li,iV as ui,iW as di,iX as fi,iY as gi,go as hi,cA as Ni,iZ as T,dX as P,gn as mi,gm as bi,aC as pi,i_ as S,di as Si,i$ as xi,j0 as Ai,aD as a,T as e,eh as l,j1 as M,e9 as O,aU as ji,aJ as B,dO as Ii,j2 as L,j3 as $,ec as Ti,cZ as D,j4 as Pi,hy as Fi,de as p,dD as F,fA as vi,j5 as d}from"./App-DIz0IRcC.js";import{C as wi}from"./ContentPageTemplate-BAegyexo.js";import{I as C}from"./DisabledItem-DiUx55LF.js";import{h as x,a as Ei}from"./pushNotificationUtils-guZ1zES2.js";import{u as Di}from"./usePrevious-KmHvzjDk.js";import{B as Ci}from"./BellThin-DybKxP54.js";import"./BackwardChevron-BGDQlEcT.js";const yi=H(E)`
2  && {
3    color: ${i=>i.theme.palette.warning.main};
4    width: 18px;
5    height: 18px;
6    margin-bottom: -3px;
7    margin-${w}: 2px;
8  }
9`;function ki(i){const{notificationsMuted:n,authentication:s,alertCommentPushNotificationsEnabled:A,pushNotificationsState:N}=i,y=Si(),K=t.jsx(xi,{to:Ai.SUBSCRIPTIONS,children:t.jsx(a,{id:e.Subscriptions.info.how_to_manage.link_to_subscriptions})}),W=t.jsx(a,{id:e.Subscriptions.info.how_to_manage.base,values:{link_to_subscriptions:K}}),[j,I]=r.useState(l.fetch(l.init())),[q,z]=r.useState(M()),[k,V]=r.useState(!1),[X,Y]=r.useState(void 0),Z=Di(i)||i,u=j.data,J=g(s)?G(u)?e.NotificationSettings.noSubscriptions:e.NotificationSettings.Foresights.description:e.General.premiumFeature,Q=c(s)?v(u)?e.NotificationSettings.noSubscriptions:e.NotificationSettings.realTimeAlerts.description:e.General.premiumFeature,ii=c(s)?v(u)?e.NotificationSettings.noSubscriptions:e.NotificationSettings.comments.description:e.General.premiumFeature;r.useEffect(()=>(O(y.formatMessage({id:e.MyProfile.notificationSettings})),Y(setInterval(()=>{const o=M();o!==o&&z(o)},1e3)),R(i),si(),()=>{O(),clearInterval(X)}),[]),r.useEffect(()=>{R(i),k&&!ji(m(Z),m(i))&&B("Notification settings changed",m(i))},[i]);function R(o){!k&&o.pushNotificationsInitalised&&(B("Notification settings viewed",m(o)),V(!0))}function m(o){return{"Allow push notifications on this device":!o.notificationsMuted,"Real Time Alerts":o.alertPushNotificationsEnabled,Comments:A}}const ti=o=>(I(l.fetchComplete(j,o)),o),ei=o=>{I(l.fetchComplete(j,void 0,o.message))};function si(){I(l.fetch(l.init())),Ii.getReportSubscriptions(i.user.id).then(ti).catch(ei)}const oi=g(s)?G(u)?t.jsx(E,{className:"labelIcon warning"}):void 0:t.jsx(L,{variant:$.FEATURE_SMALL,disabled:!0,className:"labelIcon",infoTooltipText:{id:e.General.info.featureNotAvailable.title}}),_=c(s)?v(u)?t.jsx(E,{className:"labelIcon warning"}):void 0:t.jsx(L,{variant:$.FEATURE_SMALL,disabled:!0,className:"labelIcon",infoTooltipText:{id:e.General.info.featureNotAvailable.title}});return t.jsx(Ti,{customTopNavigation:o=>t.jsx(Fi,{topNavigationTitle:y.formatMessage({id:e.MyProfile.notificationSettings}),...o}),children:t.jsx(wi,{headerIcon:Ci,header:{id:e.MyProfile.notificationSettings},hideHeaderInMobile:!0,children:t.jsxs(ni,{className:i.className,children:[t.jsx(D,{variant:"h5",className:"sectionTitle",children:t.jsx(a,{id:e.NotificationSettings.pushNotifications.title})}),t.jsx(f,{label:Ri(t.jsx(a,{id:e.NotificationSettings.allowPushNotifications.title}),s),labelIcon:h(s)?t.jsx(Li,{pushNotificationsState:N}):void 0,description:t.jsx($i,{pushNotificationsState:N,disabledByOS:q,authentication:s}),toggle:t.jsx(b,{disabled:!h(s),checked:h(s)&&!n,onToggle:o=>i.toggleNotifications(!o)})}),t.jsx(Pi,{}),t.jsx(f,{label:t.jsx(a,{id:e.NotificationSettings.subscriptionBasedNotifications.title}),description:W}),t.jsx(f,{className:"subItem",label:_i(t.jsx(a,{id:e.General.ForesightsFeature.title}),s),labelIcon:oi,toggle:t.jsx(b,{disabled:n,checked:g(s)&&i.foresightsPushNotificationsEnabled,onToggle:o=>i.setForesightsPushNotificationsEnabledAction(o)}),description:t.jsx(a,{id:J}),onClick:g(s)?void 0:i.openInsightsPremiumFeatureDialog}),t.jsx(f,{className:"subItem",label:U(t.jsx(a,{id:e.NotificationSettings.realTimeAlerts.title}),s),labelIcon:_,toggle:t.jsx(b,{disabled:n,checked:c(s)&&i.alertPushNotificationsEnabled,onToggle:o=>i.setAlertPushNotificationsEnabledAction(o)}),description:t.jsx(a,{id:Q}),onClick:c(s)?void 0:i.openNotificationsAlertsPremiumFeatureDialog}),t.jsx(f,{className:"subItem",label:U(t.jsx(a,{id:e.NotificationSettings.comments.title}),s),labelIcon:_,toggle:t.jsx(b,{disabled:n,checked:c(s)&&A,onToggle:o=>i.setAlertCommentPushNotificationsEnabledAction(o)}),description:t.jsx(a,{id:ii}),onClick:c(s)?void 0:i.openNotificationsAlertsPremiumFeatureDialog})]})})})}function f(i){return t.jsxs(F,{container:!0,className:`toggleRow ${i.className}`,onClick:i.onClick,sx:{justifyContent:"space-between"},children:[t.jsxs(F,{size:9,children:[t.jsxs(D,{variant:"h6",children:[i.label," ",i.labelIcon]}),i.description&&t.jsx(D,{variant:"body1",color:"textSecondary",children:i.description})]}),i.toggle&&t.jsx(F,{children:i.toggle})]})}const b=({disabled:i,checked:n,onToggle:s})=>t.jsx(vi,{className:"toggle",color:"primary",disabled:i,checked:n,onChange:(A,N)=>s(N)});function Ri(i,n){return h(n)?i:t.jsx(C,{children:i})}function U(i,n){return c(n)?i:t.jsx(C,{children:i})}function _i(i,n){return g(n)?i:t.jsx(C,{children:i})}function h(i){return i.hasFeature(p.Alerts)||i.hasFeature(p.Foresights)}function c(i){return i.hasFeature(p.Alerts)}function g(i){return i.hasFeature(p.Foresights)}function v(i){return i&&!x(S.Alert,i)}function G(i){return i&&!x(S.Foresight,i)}function Yi(i){return i&&!x(S.SingleQuestionReport,i)}function Zi(i){return i&&!x(S.SurveyReminder,i)}const Mi=i=>{const n=i.authenticatedUser.request.data,s=i.authenticatedUser.pushNotifications;return{showNotificationsToggle:bi(s),pushNotificationsInitalised:s.tokenReceived,pushNotificationsState:s.state,notificationsMuted:mi(s.token),foresightsPushNotificationsEnabled:T(n,P.NOTIFICATIONS_FORESIGHTS_ENABLED),alertPushNotificationsEnabled:T(n,P.NOTIFICATIONS_ALERTS_ENABLED),alertCommentPushNotificationsEnabled:T(n,P.NOTIFICATIONS_ALERTS_COMMENTS_ENABLED),user:n}},Oi={toggleNotifications:hi,setForesightsPushNotificationsEnabledAction:gi,setAlertPushNotificationsEnabledAction:fi,setAlertCommentPushNotificationsEnabledAction:di,openInsightsPremiumFeatureDialog:ui,openNotificationsAlertsPremiumFeatureDialog:li,openNotificationsCommentsPremiumFeatureDialog:ri},Bi=H(ki)`
10  padding: 16px;
11  margin-bottom: 16px;
12  ${i=>`
13    ${i.theme.breakpoints.down("lg")} {
14      margin-top: 8px;
15    }
16  `}
17  .sectionTitle {
18    padding: 16px 0;
19  }
20  .toggleRow {  
21    padding: 16px 0;    
22    &.subItem {
23      padding-top: 0px;
24      padding-${w}: 40px;
25    }
26    .toggle {
27      margin-${pi}: -8px;
28      margin-top: -8px;
29    }
30  }
31  .labelIcon {
32    &.warning {
33      color: ${i=>i.theme.palette.warning.main};
34    }
35    width: 18px;
36    height: 18px;
37    margin-bottom: -3px;
38    margin-${w}: 2px;
39    display: inline-block; 
40  }
41`,Ji=ci(Mi,Oi)(Ni(Bi));function Li(i){return Ei(i.pushNotificationsState)?t.jsx(yi,{}):null}function $i(i){return h(i.authentication)?t.jsx(a,{id:Ui(i.pushNotificationsState,i.disabledByOS)}):t.jsx(a,{id:e.NotificationSettings.allowPushNotifications.infotext})}
41function Ui(i,n){if(n)return e.NotificationSettings.pushNotificationsDisabled.device.warning;switch(i){case d.NoBrowserSupport:return e.NotificationSettings.browserNotSupported.warning;case d.Disabled:case d.DisabledInMobileApp:return ai()?e.NotificationSettings.allowPushNotifications.infotext:e.NotificationSettings.pushNotificationsDisabled.browser.warning;case d.AskLater:case d.Enabled:default:return e.NotificationSettings.allowPushNotifications.infotext}}export{Ji as default,v as warnAboutNoAlertSubscriptions,G as warnAboutNoForesightsSubscriptions,Zi as warnAboutNoReminderSubscriptions,Yi as warnAboutNoResultSubscriptions};

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.