-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code and update dependencies
- Loading branch information
1 parent
c3c1a07
commit cfad86a
Showing
13 changed files
with
115 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,51 @@ | ||
import { SpawnContext } from "@/context"; | ||
import { SpawnScreenState } from "@/enums"; | ||
import { useContext, useMemo } from "react"; | ||
import { useCallback, useContext, useMemo } from "react"; | ||
|
||
export const useSpawn = () => { | ||
const { spawnScreenState, setSpawnScreenState } = useContext(SpawnContext); | ||
export const useSpawn = (isStaking?: boolean) => { | ||
const { spawnScreenState, setSpawnScreenState, firstSpawnScreenState } = | ||
useContext(SpawnContext); | ||
|
||
const spawnPercentage = useMemo(() => { | ||
if (spawnScreenState === SpawnScreenState.RPC) return 33; | ||
if (spawnScreenState === SpawnScreenState.AGENT_FUNDING) return 66; | ||
if (spawnScreenState === SpawnScreenState.DONE) return 100; | ||
const spawnPercentage: number = useMemo(() => { | ||
if (spawnScreenState === SpawnScreenState.STAKING_CHECK) return 0; | ||
// Staking path | ||
if (isStaking) { | ||
switch (spawnScreenState) { | ||
case SpawnScreenState.RPC: | ||
return 25; | ||
case SpawnScreenState.STAKING_FUNDING: | ||
return 50; | ||
case SpawnScreenState.AGENT_FUNDING: | ||
return 75; | ||
case SpawnScreenState.DONE: | ||
return 100; | ||
default: | ||
break; | ||
} | ||
} | ||
// Non-staking path | ||
switch (spawnScreenState) { | ||
case SpawnScreenState.RPC: | ||
return 33; | ||
case SpawnScreenState.AGENT_FUNDING: | ||
return 66; | ||
case SpawnScreenState.DONE: | ||
return 100; | ||
default: | ||
break; | ||
} | ||
return 0; | ||
}, [spawnScreenState]); | ||
}, [isStaking, spawnScreenState]); | ||
|
||
const resetSpawn = () => { | ||
setSpawnScreenState(SpawnScreenState.STAKING_CHECK); | ||
}; | ||
const resetSpawnScreenState = useCallback( | ||
(): void => setSpawnScreenState(firstSpawnScreenState), | ||
[firstSpawnScreenState, setSpawnScreenState], | ||
); | ||
|
||
return { | ||
spawnScreenState, | ||
setSpawnScreenState, | ||
spawnPercentage, | ||
resetSpawn, | ||
resetSpawnScreenState, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "ESNext", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
// "resolveJsonModule": true, | ||
"moduleResolution": "Bundler", | ||
"outDir": "./dist" // Output directory for compiled JavaScript files | ||
}, | ||
"include": ["electron/**/*.ts", "electron/main.js"], // Path to your TypeScript source files | ||
"exclude": ["node_modules", "backend", "frontend", "dist"] | ||
} |