Module 470214

1,593 characters · in no known chunk
Dependencies
Required by (1)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>S});var i=n(636537),r=n(228366),s=n(439372),a=n(885386),o=n(461213),l=n(927813),u=n(38405),c=n(17928);let d=l.A.Millis.HOUR,_={lastReportedAtMs:null},h=_;class f extends c.Ay.PersistedStore{static displayName="FriendOnlineTimerStore";static persistKey="FriendOnlineTimerStore";initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_;h=e??_}isCooldownElapsed(){return null==h.lastReportedAtMs||Date.now()-h.lastReportedAtMs>=d}getState(){return h}}let E=new f(r.h,{FRIEND_ONLINE_TIMER_REPORTED:function(e){let{timestampMs:t}=e;return h.lastReportedAtMs=t,!0}});var p=n(652215),m=n(818348);let g=5*l.A.Millis.MINUTE;async function A(){try{await i.Bo.post({url:p.Rsh.USER_MEANINGFULLY_ONLINE,rejectWithError:!0})}catch(e){if(!(e instanceof i.oh)||429!==e.status)return void u.A.captureException(e,{tags:{app_context:"session_timer"}})}r.h.dispatch({type:"FRIEND_ONLINE_TIMER_REPORTED",timestampMs:Date.now()})}function I(e){return[m.cl.ONLINE,m.cl.STREAMING].includes(e)}class T extends s.A{timerId=null;actions={POST_CONNECTION_OPEN:()=>this.start(),CONNECTION_RESUMED:()=>this.start(),CONNECTION_CLOSED:()=>this.clear(),CONNECTION_INTERRUPTED:()=>this.clear(),SELF_PRESENCE_STORE_UPDATE:()=>this.start()};_initialize(){}_terminate(){this.clear()}start=()=>{a.hV.getSetting()&&E.isCooldownElapsed()&&null==this.timerId&&I(o.A.getStatus())&&(this.timerId=setTimeout(()=>{this.timerId=null,!I(o.A.getStatus())||E.isCooldownElapsed()&&A()},g))};clear=()=>{null!=this.timerId&&(clearTimeout(this.timerId),this.timerId=null)}}let S=new T}