Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NickRimmer committed Aug 26, 2023
1 parent c6a7a3d commit a7471a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/insomnia/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@

let router: any = null

var getRouter = (): any => {
const getRouter = (): any => {
if (!router) {
const root = document.querySelector("#root") as Record<string, any>;
const root = document.querySelector('#root') as Record<string, any>
if (!root) {
return;
return
}
const parameter = Object.getOwnPropertyNames(root).findLast((x) => x.startsWith("__reactContainer"));
router = root[parameter as string]?.memoizedState?.element?.props?.router;
const parameter = Object.getOwnPropertyNames(root).findLast((x) => x.startsWith('__reactContainer'))
router = root[parameter as string]?.memoizedState?.element?.props?.router
}
return router;
};
return router
}

export const getState = () => {
const router = getRouter();
return router?.state;
};
const router = getRouter()
return router?.state
}

export const getActiveWorkspaceId = (): string => {
const state = getState();
return state?.loaderData[":workspaceId"].activeWorkspace._id
const state = getState()
return state?.loaderData[':workspaceId'].activeWorkspace._id
}
export const getActiveEnvironmentId = (): string => {
const state = getState();
return state?.loaderData[":workspaceId"].activeEnvironment._id
const state = getState()
return state?.loaderData[':workspaceId'].activeEnvironment._id
}
4 changes: 2 additions & 2 deletions src/services/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export const init = async () => {
}

export const getCurrentTokenAsync = async (): Promise<StoredToken | null> => {
const activeWorkspaceId = getActiveWorkspaceId();
const activeWorkspaceId = getActiveWorkspaceId()
const activeEnvironmentId = getActiveEnvironmentId()
return await getTokenAsync(activeWorkspaceId, activeEnvironmentId ?? null)
}

export const getLatestTokenAsync = async (): Promise<StoredToken | null> => {
const activeWorkspaceId = getActiveWorkspaceId();
const activeWorkspaceId = getActiveWorkspaceId()
const tokens = await getTokensAsync(activeWorkspaceId)
if (tokens.length === 0) return null
return tokens.reduce((prev, curr) => prev.createdAt > curr.createdAt ? prev : curr, tokens[0] ?? null)
Expand Down

0 comments on commit a7471a0

Please sign in to comment.