Module 546183

1,689 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.r(t),n.d(t,{FetchState:()=>c,default:()=>I});var i,r=n(17928),s=n(228366),a=n(403362),o=n(734057),l=n(134861),u=n(232835),c=((i={}).NOT_FETCHED="NOT_FETCHED",i.FETCHING="FETCHING",i.FETCHED="FETCHED",i);let d=new Map,_=[],h=[],f="NOT_FETCHED",E=new Map,p=0;function m(){h=(_=[...d.values()]).filter(e=>{let{application:t}=e;return null==t.parent_id})}function g(e,t){if(null==t)f=e,E.clear(),p+=1;else{for(let n of t)E.set(n,e);p+=1}}class A extends r.Ay.Store{static displayName="AuthorizedAppsStore";initialize(){this.waitFor(o.A,l.A,u.A)}getNewestTokenForApplication(e){return null==e?null:d.get(e)??null}getNewestTokens(){return _}getNewestTokensForNonChildrenApplications(){return h}getFetchState(){return f}getFetchStateForApplication(e){return"FETCHING"===f||"FETCHED"===f?f:E.get(e)??f}getApplicationFetchStateVersion(){return p}}let I=new A(s.h,{USER_AUTHORIZED_APPS_REQUEST:function(e){"full"===e.request.type?g("FETCHING"):g("FETCHING",e.request.applicationIds)},USER_AUTHORIZED_APPS_REQUEST_FAILED:function(e){"full"===e.request.type?g("FETCHED"):g("FETCHED",e.request.applicationIds)},USER_AUTHORIZED_APPS_UPDATE:function(e){if(e.isFullFetch)g("FETCHED"),d=new Map(Object.entries(e.tokens).filter(a.QE)),m();else{for(let[t,n]of(g("FETCHED",Object.keys(e.tokens)),Object.entries(e.tokens)))null==n?d.delete(t):d.set(t,n);m()}},OAUTH2_TOKEN_CREATE:function(e){let{id:t,application:n,scopes:i}=e;d.set(n.id,{id:t,application:n,scopes:i}),m()},OAUTH2_TOKEN_DELETE:function(e){let{id:t,applicationId:n}=e,i=d.get(n);if(null==i||i.id!==t)return!1;d.delete(i.application.id),m()},LOGOUT:function(){d=new Map,_=[],h=[],f="NOT_FETCHED",E.clear(),p+=1}})}