fix: refactor initPortal to return the instance

This commit is contained in:
Derrick Hammer 2023-06-23 19:30:48 -04:00
parent 5db121774e
commit 89d24393e5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 5 deletions

View File

@ -20,7 +20,7 @@ export function maybeInitDefaultPortals(): ErrTuple {
}
for (const portal of DEFAULT_PORTAL_LIST) {
initPortal(portal);
addActivePortal(initPortal(portal));
}
return [null, null];
@ -58,7 +58,7 @@ export function addActivePortal(portal: Client) {
ACTIVE_PORTALS.add(portal);
}
export function initPortal(portal: Portal) {
export function initPortal(portal: Portal): Client {
const sessions = getPortalSessions();
let jwt: string | null = null;
if (sessions) {
@ -67,14 +67,12 @@ export function initPortal(portal: Portal) {
}
}
const client = new Client({
return new Client({
email: generatePortalEmail(portal),
portalUrl: portal.url,
privateKey: generatePortalKeyPair(portal).privateKey,
jwt: jwt as string,
});
addActivePortal(client);
}
export function getPortalSessions() {