Module 470214

1,563 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:()=>T});var i=n(636537),r=n(228366),s=n(439372),a=n(461213),o=n(927813),l=n(38405),u=n(17928);let c=o.A.Millis.HOUR,d={lastReportedAtMs:null},_=d;class f extends u.Ay.PersistedStore{static displayName="FriendOnlineTimerStore";static persistKey="FriendOnlineTimerStore";initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;_=e??d}isCooldownElapsed(){return null==_.lastReportedAtMs||Date.now()-_.lastReportedAtMs>=c}getState(){return _}}let h=new f(r.h,{FRIEND_ONLINE_TIMER_REPORTED:function(e){let{timestampMs:t}=e;return _.lastReportedAtMs=t,!0}});var p=n(652215),E=n(818348);let m=5*o.A.Millis.MINUTE;async function g(){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 l.A.captureException(e,{tags:{app_context:"session_timer"}})}r.h.dispatch({type:"FRIEND_ONLINE_TIMER_REPORTED",timestampMs:Date.now()})}function A(e){return[E.cl.ONLINE,E.cl.STREAMING].includes(e)}class I 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=()=>{!h.isCooldownElapsed()||null!=this.timerId||A(a.A.getStatus())&&(this.timerId=setTimeout(()=>{this.timerId=null,!A(a.A.getStatus())||h.isCooldownElapsed()&&g()},m))};clear=()=>{null!=this.timerId&&(clearTimeout(this.timerId),this.timerId=null)}}let T=new I}