Build 545032stable
Module 546183
1,619 characters · in no known chunkDependencies
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,_=[],f=[],h="NOT_FETCHED",p=new Map,E=0;function m(){f=(_=[...d.values()]).filter(e=>{let{application:t}=e;return null==t.parent_id})}function g(e,t){if(null==t)h=e,p.clear(),E+=1;else{for(let n of t)p.set(n,e);E+=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 f}getFetchState(){return h}getFetchStateForApplication(e){return"FETCHING"===h||"FETCHED"===h?h:p.get(e)??h}getApplicationFetchStateVersion(){return E}}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()}})}