-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: display status of sending request steps * fix: activeRequest id is necessary for different cases * chore: rephrase step name and improve its typing * feat: show sending status for mock routes * fix: make text vertically aligned and reformat code * fix: spinner line height * feat: add after-response script step to the progress * fix: add useEffect deps * refactor: add a function for finish last timing record and compact logic a bit * simplify * add tooltip * fix timer * use duration * improve time tag * refactor: replace callback with hook * fix: add the missing hook * rename isExecuting * delay snippet * works * rename bridge methods * remove undefined initial state * force stop execution before cancel * fix time tag layout * fix hang * simplify api * tidy up --------- Co-authored-by: jackkav <jackkav@gmail.com>
- Loading branch information
Showing
18 changed files
with
239 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { BrowserWindow } from 'electron'; | ||
|
||
export type StepName = 'Executing pre-request script' | ||
| 'Rendering request' | ||
| 'Sending request' | ||
| 'Executing after-response script'; | ||
|
||
export interface TimingStep { | ||
stepName: StepName; | ||
startedAt: number; | ||
duration?: number; | ||
} | ||
export const executions = new Map<string, TimingStep[]>(); | ||
export const getExecution = (requestId?: string) => requestId ? executions.get(requestId) : []; | ||
export const startExecution = (requestId: string) => executions.set(requestId, []); | ||
export function addExecutionStep( | ||
requestId: string, | ||
stepName: StepName, | ||
) { | ||
// append to new step to execution | ||
const record: TimingStep = { | ||
stepName, | ||
startedAt: Date.now(), | ||
}; | ||
const execution = [...(executions.get(requestId) || []), record]; | ||
executions.set(requestId, execution); | ||
for (const window of BrowserWindow.getAllWindows()) { | ||
window.webContents.send(`syncTimers.${requestId}`, { executions: executions.get(requestId) }); | ||
} | ||
} | ||
export function completeExecutionStep(requestId: string) { | ||
const latest = executions.get(requestId)?.at(-1); | ||
if (latest) { | ||
latest.duration = (Date.now() - latest.startedAt); | ||
} | ||
for (const window of BrowserWindow.getAllWindows()) { | ||
window.webContents.send(`syncTimers.${requestId}`, { executions: executions.get(requestId) }); | ||
} | ||
} |
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
Oops, something went wrong.