83 lines
2.2 KiB
TypeScript
83 lines
2.2 KiB
TypeScript
// Metro module 5534 (f5535).
|
|
import { useCallback } from "react";
|
|
import ConnectedAccountsStore from "../../../stores/ConnectedAccountsStore";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import ConnectedAccountsActionCreators from "../../../actions/ConnectedAccountsActionCreators";
|
|
let env3402 = {};
|
|
export function useProviderConnection(a0) {
|
|
let env14907 = {
|
|
$parent: env3402
|
|
};
|
|
env14907[0] = a0;
|
|
const stateFromStores = useStateFromStores([ConnectedAccountsStore], () => {
|
|
const r5 = env14907[0];
|
|
return r5 != null ? ConnectedAccountsStore.getAccount(null, r5) : null;
|
|
});
|
|
const stateFromStores2 = useStateFromStores([ConnectedAccountsStore], () => ConnectedAccountsStore.isFetching());
|
|
const hasConnection = stateFromStores != null && !stateFromStores.revoked;
|
|
let c14908_0 = async (c29521_0) => {
|
|
let r59;
|
|
let location2;
|
|
let c29521_5 = 0;
|
|
let c31373_0;
|
|
L20: {
|
|
try {
|
|
c31373_0 = void 0;
|
|
const r18 = env14907[0];
|
|
if (r18 == null) {
|
|
break L20;
|
|
}
|
|
c29521_5 = 1;
|
|
location2 = c29521_0;
|
|
if (c29521_0 == null) {
|
|
location2 = "Account Linking";
|
|
}
|
|
c31373_0 = await ConnectedAccountsActionCreators.authorize(r18, {
|
|
location: location2
|
|
});
|
|
r59 = c31373_0.ok ? c31373_0.body?.url != null ? {
|
|
success: true,
|
|
url: c31373_0.body.url
|
|
} : {
|
|
success: false
|
|
} : {
|
|
success: false
|
|
};
|
|
c29521_5 = 0;
|
|
} catch ($e) {
|
|
let r7 = $e;
|
|
if (c29521_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c29521_5 = 0;
|
|
} catch ($e) {
|
|
r7 = $e;
|
|
if (c29521_5 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return {
|
|
success: false
|
|
};
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
return r59;
|
|
}
|
|
return {
|
|
success: false
|
|
};
|
|
};
|
|
return {
|
|
loading: stateFromStores2,
|
|
hasConnection,
|
|
canConnect: a0 != null,
|
|
startConnection: useCallback(function() {
|
|
return c14908_0.apply(this, arguments);
|
|
}, [a0]),
|
|
account: stateFromStores
|
|
};
|
|
}
|